I want to visualize connections in a network. The general structure is constant, but single nodes are added and removed quite frequently. I have tried fdp, sfdp and neato. In all cases, I can try different seeds with start until I eventually find a layout that looks okay. I would like to find a more reliable approach.
The documentation suggests that there is a pos attribute. I hope to use it to feed an initial position (either fixed or of a previous run) into the algorithm. I could not get it to work, so I read the source. There is a getPos function. The position data is forwarded to the layout function. I found these lines in spring_electrical.c:
x allegedly holds the user-supplied positions. We get the coarsest grid, then we check if it is the finest grid. This never seems to be the case. Always, the new memory is allocated. The user-supplied information seems to be disregarded. Unfortunately, there is no documentation regarding multilevel_spring_electrical_embedding and x is not the most intuitive parameter name, so I could be completely mistaken. Anyhow, I could not figure out how to make this work. Is this a bug or am I using it wrong?
In this sample, I tried to give some hints for a horizontal layout. neato -s does something, but I cannot say I feel in control. When I set pos="-12, 0" for Anon49, hoping it will end up left of Anon04 to eliminate the unsightly crossed edges, I end up with a completely different graph. sfdp seems to ignore the pos attribute completely.
To “nail down” a node (pin in Graphviz language), either add a bang (!) to the end of the pos (e.g. pos=“2,4!”) or add the attribute pin=true. (see pos | Graphviz and point | Graphviz)
note that input pos units are inches, but output units are points (inch/72)
Below is a resulting graph after adding “!” to each pos, running neato with no other attributes set.
I hoped for something “softer” than “pinning”. Thank you for the hint not to use neato's-s switch. I ended up pinning all the nodes, effectively doing the layout manually. Not ideal, but okay for now. I hope to find a true automatic layout mechanism. graphviz does not seem to be the right tool for the job.
It’s intrinsic to the multilevel layout algorithm, because it starts with a coarsened (simplified) representation of the network, then expands it until the full node set is reached. It is not clear how to cope with combining multiple nodes that have potentially very different layout coordinates. Not saying it couldn’t be done or this problem hasn’t been solved elsewhere but it would take some effort. For similar reasons, multilevel layout doesn’t cope with variable (user-specified) input edge lengths.
There could be some good (student? hacker?) projects based on this.
In graph drawing, make N layouts in parallel and automatically choose the best one(s).
In interactive editing, support fine tuning with a scalable constraint-based graphics editor. Allow all kinds of constraints: separation, alignment, compaction. Tim Dwyer made a lot of progress on this with WebCoLa but it’s not maintained any more. This might be an example of how better technology doesn’t necessarily win over popularity, flexibility/portability, and some level of community support.
I remember several times starting to fix this before remembering that it wasn’t that easy. The obvious approach is to give a coarse node some average position of its component nodes, but this sounds like it could cause problems. Interestingly, even allowing pinned nodes as in neato and fdp can cause problems with the layout, iirc.