How to run neato from pygraphviz on Windows

后端 未结 4 1280
粉色の甜心
粉色の甜心 2020-12-30 09:50

I am trying to use pygraphviz and networkx in python (v 2.7) to create a network map. I found a script that looks very useful on stackoverflow:

import netwo         


        
4条回答
  •  情歌与酒
    2020-12-30 10:38

    The problem is that pygraphviz call an external program, a part of the graphviz suite called neato, to draw the graph. What is happening is that you doesn't have graphviz installed and when python try to call it it complains about not finding it. Actually pygraphviz is just a wrapper that gives you the possibility to call graphviz from inside python, but per se doesn't do anything and doesn't install graphviz by default.

    The easiest solution is to try a different solution for the plot instead of neato. the accepted option are:

    neato
    dot
    twopi
    circo
    fdp
    nop
    

    try one of those and see if one of them works. Otherwise you can install graphviz, that will give you the required program. It's and open-source program available on every platform, so it shouldn't be a problem to install it.

    see at http://www.graphviz.org/

    If you simply need to have a sketch of the graph you can use the networkx.draw function on a networkx graph, that uses matplotlib to create an interactive plot.

    import networkx as nx
    G = G=nx.from_numpy_matrix(A)
    nx.draw(G)
    

提交回复
热议问题