how to compress a graph?

I some time get a bigger than neccesary layout when applying labels to edges how do I avoid that?
in the following example the space between ab1 and ab2 is unneccessary large

Example:

digraph{
rankdir=LR
a->ab1->ab2->b
a->b[label=between]
}

digraph{
rankdir=LR
c->cd1->cd2->d
c->d
}

Normal edge labels in dot are

Normal edge labels in dot are heavyweight objects, basically implemented as nodes between ranks of real nodes. This guarantees space for the label, but this can also cause complexity in edge routing as well as wasted space. The current version of Graphviz supports external labels, which are placed after the graph is laid out. These don't distort the layout, but it then may not be able to place all of the labels without overlap.
 
For your graph, use a -> b [xlabel=between], assuming you have a version of Graphviz later than August 2011. For more info, see http://www.graphviz.org/content/attrs#dxlabel
 

Recent comments