Add edge-weights to plot output in networkx
You'll have to call nx.draw_networkx_edge_labels()
, which will allow you to... draw networkX edge labels :)
EDIT: full modified source
#!/usr/bin/pythonimport networkx as nximport matplotlib.pyplot as pltG=nx.Graph()i=1G.add_node(i,pos=(i,i))G.add_node(2,pos=(2,2))G.add_node(3,pos=(1,0))G.add_edge(1,2,weight=0.5)G.add_edge(1,3,weight=9.8)pos=nx.get_node_attributes(G,'pos')nx.draw(G,pos)labels = nx.get_edge_attributes(G,'weight')nx.draw_networkx_edge_labels(G,pos,edge_labels=labels)plt.savefig(<wherever>)