I just included this for completeness. I learned a lot from marius and mdml. Here are the weights. Sorry for the arrows. It seems that I'm not the only one who said that this will not help. I could not do this with the ipython laptop I had to go straight with python with, which was a problem getting my weights in the beginning.
import networkx as nx import numpy as np import matplotlib.pyplot as plt import pylab G = nx.DiGraph() G.add_edges_from([('A', 'B'),('C','D'),('G','D')], weight=1) G.add_edges_from([('D','A'),('D','E'),('B','D'),('D','E')], weight=2) G.add_edges_from([('B','C'),('E','F')], weight=3) G.add_edges_from([('C','F')], weight=4) val_map = {'A': 1.0, 'D': 0.5714285714285714, 'H': 0.0} values = [val_map.get(node, 0.45) for node in G.nodes()] edge_labels=dict([((u,v,),d['weight']) for u,v,d in G.edges(data=True)]) red_edges = [('C','D'),('D','A')] edge_colors = ['black' if not edge in red_edges else 'red' for edge in G.edges()] pos=nx.spring_layout(G) nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_labels) nx.draw(G,pos, node_color = values, node_size=1500,edge_color=edge_colors,edge_cmap=plt.cm.Reds) pylab.show()

Back2Basics Nov 22 '13 at 0:24 2013-11-22 00:24
source share