Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import networkx as nx
- import matplotlib.pyplot as plt
- G = nx.MultiDiGraph()
- G.add_edges_from([
- ('t1', 'c1'),
- ('t1', 'c2'),
- ('c1', 'c2'),
- ('c2', 'c1'),
- ('p2', 'c1'),
- ('c2', 'p2')
- ])
- attrs = {'c1':{'key':100},
- 'c2':{'key':50},
- 't1':{'key':15},
- 'p2':{'key':30}}
- nx.set_node_attributes(G, attrs)
- node_sizes = [a['key']*30 for n, a in G.nodes(data=True)]
- # drawing ...
- pos = {key: [i*3, 0] for key, i in zip(attrs, range(len(attrs)))}
- print(pos)
- nx.draw(G, pos, with_labels=True,
- cmap=plt.get_cmap('jet'),
- node_size=node_sizes,
- arrows=True, arrowsize=40)
Add Comment
Please, Sign In to add comment