I need to create a graph where some set of nodes and edges (MainSet) needs to be well centered or organized while other set of nodes and edges (SubSet) may have “worse” positioning.
On my ideal word, I would create a graph with the elements of the MainSet and let graphviz layout it. After that I would fix all nodes and edges positions on that graph and then add the elements of the SubSet.
Ive tryed to create a subgraph/cluster to MainSet and SubSet. The result is ok, but still messes a lot with the layout of the elements of the MainSet.
I may have some ideas, but I dont know how to execute them:
Is it possible to use DOT to position elements of the MainSet. Get those positions and use something like FDP or NEATO to fix the positions of MainSet and let it organize the SubSet?
Is it possible to force a Node to move around to try to find the position in the layout more than another node?
Is it possible to create edges that ignore node positions? (that would not solve the problem, but at least the cluster solution would become more organized).
This is such a great question. I don’t think we address it very well in Graphviz. It would be excellent for someone to work on this problem. It might be possible to cobble together some kind of solution as suggested in point #1. Also you could try drastically increasing the weights of the MainSet edges and see how that helps. If our code was just a little more flexible this would be easy to experiment with. “It would be a good summer intern project.”
[These ideas are not well tested. Most are not tested at all]
use dot on MainSet & pin (pin | Graphviz) the node locations:
Create a graph that only contains your “MainSet”. This will probably work best if everything is inside one cluster.
run dot -Tdot mainset.gv | gvpr -c 'N{$.pin="true"}' > intermediate.dot Nodes now pinned.
add the nodes and edges of the SubSet to intermediate.dot (at the end of the file, but inside the closing brace.
run fdp -s -Tpng intermediate.dot >all.png (fdp will honor clusters) (note the -s option)
the weight and group attributes “kind of” do this. (“kind of”)
Yes, you can create edges that ignore node placement. Splines are quite difficult, straight edges without arrowheads are easy, and straight edges with arrowheads are in-between. (see Fun with edges! to start) (more info available if needed)