pygraphviz_layout with fixed positions #7433
-
Dear community, I have a hierarchical network DiGraph with nodes already positioned using pygraphviz_layout (program dot). I want to add new nodes (and edges) to this DiGraph. These new nodes need to be positioned, but if I run a new pygraphviz_layout, the previously positioned nodes have their positions modified, and I don't want that. I want to position only the new nodes (relative to the old nodes). I've only found the spring_layout function to fix node positions, but the results are not hierarchical and the spring_layout position is not very compatible with the position given by dot. Thank you for your help, Steven |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think you are actually looking for a GraphViz feature... pygraphviz is a python interface to the GraphViz library. It looks like adding a NetworkX's spring_layout allows you to fix some nodes (as you mention above). |
Beta Was this translation helpful? Give feedback.
I think you are actually looking for a GraphViz feature... pygraphviz is a python interface to the GraphViz library.
It looks like adding a
!
character to the existing pos string as described in the graphviz docs. Then theneato
andfdp
layout routines take the dot file and add positions to the nodes that don't have!
in their pos string. There are many other sources of info for how graphviz does layout that I'm not familiar with. That might be a direction to focus your search.NetworkX's spring_layout allows you to fix some nodes (as you mention above).