I'm trying to compute layouts for a graph that I built using networkx; let's call the graph G
. I'm using Javascript to actually render the graph, so all I need right now is to compute the positions of the nodes using a layout algorithm. (I don't want to use Javascript tools like d3 force layouts because the computations take awhile for large graphs and so I would rather do the heavy lifting server-side.)
Here's a line of code which works for me and leads to a successful graph visualization:
layout = networkx.spring_layout(G)
However, this algorithm is both slow and not very pretty. So I thought I would try Graphviz:
layout = networkx.graphviz_layout(G)
I'm running Python 3.4 in OSX, so I first installed Graphviz using:
brew install graphviz
pip install graphviz
pip install pydotplus
(I first tried installing the pydot package instead of pydotplus, but it seems that the pydot package does not support Python 3.)
When I try to call graphviz_layout
I end up with:
AttributeError: 'NoneType' object has no attribute 'get_node'
triggered by the line:
node=Q.get_node(pydot_node)
in nx_pydot.py. I'm sort of hoping that this is a known bug which someone can tell me how to fix, but I haven't found anything so far. In case nobody knows a simple fix I will not actively discourage people from recommending other Python packages which compute (but not necessarily render) graph layouts which support large graphs, though it seems that it is illegal for me to explicitly ask for this...