The last step in all of my graphs (rendered with dot) is fine-tuning their appearance. I have tried a number of strategies, but maybe someone has something I haven’t tried.
Here’s what I’ve done so far:
- adjusting the weight of edges
This is often an easy way to move two connected nodes closer together, but it also tries to make the edge straight, so sometimes it moves those nodes closer to the middle of the graph. And it usually has unintended consequences. In this graph, I’m repositioning mantrahS, mementoL, and reminiscentia, but those aren’t the only nodes that move. (Making the digraph strict lets me add edge weights to the bottom of the code, which makes it easier to change them later.)
[dot]
strict digraph men {
node [shape=none]
edge [arrowsize=.5]
nodesep=.05
men -> {gamundiz mensL meminisse reminisci monere mnemon mantrahS} [sametail=1]
gamundiz -> gemynd -> ymund -> mind
mensL -> mentalis -> mentalOF -> mentalME -> mental
meminisse -> mementoL -> memento
reminisci -> reminiscentia -> reminiscence
monere -> praemonere -> praemonitio -> premonition
mnemon -> mnemonikosG -> mnemonicusL -> mnemonic
mantrahS -> mantra
{rank=sink mind mental memento reminiscence premonition mnemonic mantra}
}
[/dot]
[dot]
strict digraph men {
node [shape=none]
edge [arrowsize=.5]
nodesep=.05
men -> {gamundiz mensL meminisse reminisci monere mnemon mantrahS} [sametail=1]
gamundiz -> gemynd -> ymund -> mind
mensL -> mentalis -> mentalOF -> mentalME -> mental
meminisse -> mementoL -> memento
reminisci -> reminiscentia -> reminiscence
monere -> praemonere -> praemonitio -> premonition
mnemon -> mnemonikosG -> mnemonicusL -> mnemonic
mantrahS -> mantra
{rank=sink mind mental memento reminiscence premonition mnemonic mantra}
men -> mantrahS [weight=2]
}
[/dot]
[dot]
strict digraph men {
node [shape=none]
edge [arrowsize=.5]
nodesep=.05
men -> {gamundiz mensL meminisse reminisci monere mnemon mantrahS} [sametail=1]
gamundiz -> gemynd -> ymund -> mind
mensL -> mentalis -> mentalOF -> mentalME -> mental
meminisse -> mementoL -> memento
reminisci -> reminiscentia -> reminiscence
monere -> praemonere -> praemonitio -> premonition
mnemon -> mnemonikosG -> mnemonicusL -> mnemonic
mantrahS -> mantra
{rank=sink mind mental memento reminiscence premonition mnemonic mantra}
men -> mantrahS [weight=2]
meminisse -> mementoL [weight=2]
}
[/dot]
[dot]
strict digraph men {
node [shape=none]
edge [arrowsize=.5]
nodesep=.05
men -> {gamundiz mensL meminisse reminisci monere mnemon mantrahS} [sametail=1]
gamundiz -> gemynd -> ymund -> mind
mensL -> mentalis -> mentalOF -> mentalME -> mental
meminisse -> mementoL -> memento
reminisci -> reminiscentia -> reminiscence
monere -> praemonere -> praemonitio -> premonition
mnemon -> mnemonikosG -> mnemonicusL -> mnemonic
mantrahS -> mantra
{rank=sink mind mental memento reminiscence premonition mnemonic mantra}
men -> mantrahS [weight=2]
meminisse -> mementoL [weight=2]
reminisci -> reminiscentia [weight=2]
}
[/dot]
- rank=same
I always use this (or rank=sink, which has the same effect in all of my graphs) to align the bottom row, and sometimes I add more subgraphs at the end to fine-tune. Sometimes I’d rather have the nodes staggered to take up less horizontal space, though, and I don’t think that’s a thing GraphViz does. I’ve tried using an invisible parallel graph to enforce an order on all the ranks, but the minimum ranksep seems to be .1, which is too big if I want to define a lot of ranks and make each edge of my visible graph span at least two ranks. - style=invis
There may be more I could do with invisible edges and nodes, but I don’t want them to make the finished graph bigger. - clusters
Ideally, I’d divide the graph into a number of ordered horizontal strata and tell the graph which stratum to place each node in. Or divide a left-to-right graph into vertical strata. Clusters definitely don’t do that. At all.
Going back to rank=same, there’s one more thing on my wishlist, though I don’t need it. It lines up the centers of all the nodes in a subgraph, which is great for uniform nodes. But on this graph, I’d rather line up the bottoms of all the nodes:
(FYI, not a problem, but the integrated dot renderer didn’t like my HTML-style labels.)