Fix Dot "overlap"?

see attached image

I know that I can fix it using a bunch of subgraphs but is there a easier way?
Setting for Dot that I can use?

Thanks
Thomas

AttachmentSize
overlap.png117.26 KB

You could try increasing the

You could try increasing the value of nodesep, but I think this will only spread the nodes out without removing the overlap. (The irony is dot tries so hard to remove extra space.) It seems to me using a cluster is really what you are trying to achieve, and it seems pretty simple to me. The question is, are the clusters inherent in your graph so you can identify them before hand? If not, then you will need to add the clusters after seeing the drawing. If that's the case, and your graph is really tree-like, as it appears, it may be simpler to use a different type of layout.

It would be nice if Dot had a

It would be nice if Dot had a setting for this. To me it is a different type of tree layout that I have seen many times, seems to be pretty common.

erg: "Are the clusters inherent in your graph so you can identify them before hand?" - Yes, but I will need to add some code to generate the clusters.

erg: "it may be simpler to use a different type of layout." - Do you mean something different that Dot? Do you have anything to recommend?

Thanks

 

Usually it is fairly easy to

Usually it is fairly easy to emit a "subgraph clusterX {...}" wrapper, but I don't know your circumstances.

I haven't looked for a while, but there should be some simple tree drawing code around. Most of these algorithms are fairly straightforward. Here is one possibility, assuming you have a rooted tree in a file x.gv : run

dot x.gv | gvpr -c -f tree.g | neato -n -Tpng > x.png

where tree.g is a file containing

BEGIN {
double spread[node_t];
double startx[node_t];
double x, sep;
node_t n, rootn;

void setRoot (graph_t g) {
if (hasAttr(g,"root") && (rootn = isNode (g, aget(g,"root"))))
return;
for (n = fstnode(g); n; n = nxtnode(n)) {
if (n.indegree == 0) {
rootn = n;
return;
}
}
printf(2, "No root found\n");
exit (1);
}

void setSep (graph_t g) {
if (hasAttr(g,"nodesep") && ((sep = g.nodesep) > 0))
return;
else
sep = 18.0;
}

}
BEG_G {
setRoot ($);
setSep ($);
$tvroot = rootn;
$tvtype = TV_postfwd;
}
N {
startx[$] = -spread[$]/2;
spread[$] = MAX(72.0 * $.width, spread[$]);
if ($tvedge) {
n = $tvedge.tail;
if (spread[n]) {
spread[n] += spread[$] + sep;
} else {
spread[n] = spread[$];
}
}
}
BEG_G {
$tvroot = rootn;
$tvtype = TV_fwd;
}
N {
neww = spread[$];
if ($tvedge) {
n = $tvedge.tail;
x = startx[n] + neww/2;
startx[n] += neww + sep;
}
else
x = neww/2;
$.pos = sprintf("%.5g,%s", x, yOf($.pos));

startx[$] += x;
}

Recent comments