1/* computes the bounding box of a graph based on its nodes
2   taking into account clusters and node sizes.
3 */
4BEGIN {
5  double x, y, w2, h2;
6  double llx, lly, urx, ury;
7  double llx0, lly0, urx0, ury0;
8
9  graph_t clustBB (graph_t G) {
10    graph_t sg;
11    for (sg = fstsubg(G); sg; sg = nxtsubg(sg)) {
12	  sg = clustBB(sg);
13    }
14	if (G.name == "cluster*") {
15      sscanf (G.bb, "%lf,%lf,%lf,%lf", &llx0, &lly0, &urx0, &ury0);
16      if (llx0 < llx) llx = llx0;
17      if (lly0 < lly) lly = lly0;
18      if (urx0 > urx) urx = urx0;
19      if (ury0 > ury) ury = ury0;
20    }
21    return G;
22  }
23}
24BEG_G {
25  llx = 1000000; lly = 1000000; urx = -1000000; ury = -1000000;
26}
27N {
28  sscanf ($.pos, "%lf,%lf", &x, &y);
29  w2 = (36.0*(double)$.width);
30  h2 = (36.0*(double)$.height);
31  if ((x - w2) < llx) llx = x - w2;
32  if ((x + w2) > urx) urx = x + w2;
33  if ((y - h2) < lly) lly = y - h2;
34  if ((y + h2) > ury) ury = y + h2;
35}
36END_G {
37  clustBB ($);
38  $.bb = sprintf ("%lf,%lf,%lf,%lf", llx, lly, urx, ury);
39}
40