pos = nx.spring_layout(G) nx.draw_networkx(G, pos, with_labels=True, font_weight='bold') labels = nx.get_edge_attributes(G, 'weight') nx.draw_networkx_edge_labels(G, pos, edge_labels=labels)