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) , seek draw graph using matplotlib, ignores multiple edges.
how can create draw multiple edges ?
graphviz job drawing parallel edges. can utilize networkx writing dot file , processing graphviz (e.g. neato layout below). you'll need pydot or pygraphviz in add-on 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
on networkx 1.11 , newer, nx.write_dot
doesn't work per issue on networkx github. workaround phone call write_dot
using
from networkx.drawing.nx_pydot import write_dot
or
from networkx.drawing.nx_agraph import write_dot
python-2.7 networkx
No comments:
Post a Comment