~ubuntu-branches/ubuntu/lucid/graphviz/lucid-updates

« back to all changes in this revision

Viewing changes to cmd/gvpr/lib/group.g

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2008-06-19 20:23:23 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619202323-ls23h96ntj9ny94m
Tags: 2.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build depend on liblualib50-dev instead of liblua5.1-0-dev.
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev or python2.5-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Collapse all nodes with group = X into a single node */
 
2
BEG_G {
 
3
  node_t metaN; 
 
4
  graph_t g = graph ("metagraph", "S");
 
5
  $tvtype = TV_ne;
 
6
  $O = g;
 
7
}
 
8
 
 
9
  /* create only one node with given name/value */
 
10
N[group == "X"] {
 
11
  if (!metaN) {
 
12
    metaN = node (g, $.name);
 
13
  }
 
14
}
 
15
 
 
16
  /* duplicate all others */
 
17
N[group != "X"] { node (g, $.name); }
 
18
 
 
19
  /* Create an edge only if at least one of the nodes
 
20
   * is not a collapsed node */
 
21
E {
 
22
  node_t t;
 
23
  node_t h;
 
24
  if ($.tail.group == "X") { 
 
25
    if ($.head.group == "X") return;
 
26
    t = metaN;
 
27
    h = node (g, $.head.name);
 
28
  }
 
29
  else if ($.head.group == "X") {
 
30
    t = node (g, $.tail.name);
 
31
    h = metaN;
 
32
  }
 
33
  else {
 
34
    t = node (g, $.tail.name);
 
35
    h = node (g, $.head.name);
 
36
  }
 
37
  edge (t, h, "");
 
38
}
 
39
 
 
40
  /* set g to be output graph */