0

I am attempting to use python and networkx to draw a graph that has multiple edges between nodes. I am able to create the graph object using networkx.MultiGraph object

To be clear, my problem here is that when networkx draws the visualized graphs, only one edge appears between nodes that have 2 edges.

From my output below, there are multiple edges shown between A,B and C,D. However, my graphs don't show the multiple edges.

Is creating a plot that shows the multiple edges possible? From scouring the internets and from my testing, I can't find a way, but it seems like there should be.

Thanks!

G = nx.MultiGraph()
G.add_nodes_from(nodes)
G.add_edges_from(edges)
nx.draw(G, with_labels=True) #with_labels=True shows the node names on the graph

plt.show()


>>> G.nodes()
['A', 'C', 'B', 'E', 'D', 'F']
>>> G.edges()
[('A', 'C'), ('A', 'B'), ('A', 'B'), ('A', 'D'), ('C', 'D'), ('C', 'D'), ('B', 'E'), ('B', 'D'), ('E', 'D'), ('D', 'F')]
>>> 

output plot does not show multiple edges

  • 4
    Does [this](http://stackoverflow.com/questions/14943439/how-to-draw-multigraph-in-networkx-using-matplotlib-or-graphviz) answer solve your problem? – one_observation Jan 06 '16 at 00:02
  • Ah, yes it does! I'm having trouble getting anaconda python to understand that it has graphviz installed already (it won't let me import it), but yes, this problem will be solved once I crack that code. Thanks! – Timothy Fiola Jan 06 '16 at 16:22

0 Answers0