python 2.7 - how to draw multigraph in networkx using matplotlib or graphviz -


when pass multigraph numpy adjacency matrix networkx (using from_numpy_matrix function) , try draw graph using matplotlib, ignores multiple edges.

how can make draw multiple edges ?

graphviz job drawing parallel edges. can use networkx writing dot file , processing graphviz (e.g. neato layout below). you'll need pydot or pygraphviz in addition networkx

in [1]: import networkx nx  in [2]: g=nx.multigraph()  in [3]: g.add_edge(1,2)  in [4]: g.add_edge(1,2)  in [5]: nx.write_dot(g,'multi.dot')  in [6]: !neato -t png multi.dot > multi.png 

enter image description here

on networkx 1.11 , newer, nx.write_dot doesn't work per issue on networkx github. workaround call write_dot using

from networkx.drawing.nx_pydot import write_dot

or

from networkx.drawing.nx_agraph import write_dot


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -