When drawing a graph, it is impossible to set specific labels for each node. According to the documentation, the draw_networkx_labels method is used for drawing labels, but for some reason it does not work (although I did it before).
Here is the code used:
import networkx as nx import matplotlib.pyplot as plt edges = [(0, 2), (1, 2), (2, 3), (2, 4)] G = nx.Graph() G.add_edges_from(edges) pos = nx.spring_layout(G) # получим метки узлов # 1 -> 111 labels = dict((i, str(i)*3) for i in range(5)) # рисуем граф nx.draw_networkx(G, pos=pos, with_labels=False) # рисуем метки nx.draw_networkx_labels(G, pos=pos, labels=labels) plt.savefig('labels.png') It should work like this, but it does not work: 
As it turned out, this problem appears in pycharm, while in jupyter notebook it works out as it should.
NetworkXandmatplotlib? - MaxU