Set bounding box position in neato

I am using neato as layout enginge for creating graph layouts from the command line. As with release 2.38.0 - the bounding box position switched from 0,0 (every time) to any position. I read the changelogs for release 2.38.0:

"Modify neato to avoid unnecessary translations of output. This allows positions given on input to remain the same on output."

This maybe helps other people to avoid translations, but i am dependend on the position 0,0 of the bounding box. Any other layout (default, fdp, sfdp) sets it to 0,0. Only neato perfoms like this.

Is there a config variable or something else that gives me the old behaviour back? I am using the following input and command:

Command: dot -K neato

Input:
digraph 130 {
dir_131 [
shape = box,
id = 131,
type = "NODE",
height = "0.61111"
];
}

Output:
digraph 130 {
graph [bb="-30,-22,30,22"];
node [label="\N"];
dir_131 [height=0.61111,
id=131,
pos="0,0",
shape=box,
type="NODE",
width=0.83333];
}

Thanks in advance

fadh

A fair cop. I have put back

A fair cop. I have put back the old behavior, with a new attribute to get the new behavior. (The changes will be in tomorrow's packages.)

If you can't update immediately, you can either edit lib/neatogen/neatoinit.c, changing the occurrences of doEdges to spline_edges, and rebuild. Or pipe your output through gvpr

    neato x.gv | gvpr -c -f translate.g

where x.gv is your input graph and translate.g is a file containing the gvpr program

/* Translate the graph so the lower-left point of the bounding box is at the origin.
 * We rely on bounding box being set.
 */
BEGIN {
  double llx, lly, urx, ury;
  double x, y;
  int cnt, sz;

  char* transE (char* p) {
    char* newpos = "";
    cnt = sscanf (p, "e,%lf,%lf%n", &x, &y, &sz);
    if (cnt == 2) {
      newpos = newpos + sprintf ("e%lf,%lf ", x-llx, y-lly);
      p = substr(p, sz);
    }
    cnt = sscanf (p, "s,%lf,%lf%n", &x, &y, &sz);
    if (cnt == 2) {
      newpos = newpos + sprintf ("s%lf,%lf ", x-llx, y-lly);
      p = substr(p, sz);
    }

    while (sscanf (p, "%lf,%lf%n", &x, &y, &sz) == 2) {
      newpos = newpos + sprintf ("%lf,%lf ", x-llx, y-lly);
      p = substr(p, sz);
    }

    return newpos;
  }
}
BEG_G {
  sscanf($.bb, "%f,%f,%f,%f", &llx, &lly, &urx, &ury);
  $.bb = sprintf ("0,0,%.05f,%.05f", urx-llx, ury-lly);
}
N {
    sscanf ($.pos, "%f,%f", &x, &y);
    $.pos = sprintf ("%f,%f", x-llx, y-lly);
}
E {
  $.pos = transE($.pos);
}

 

Recent comments