Debian Codegraph @

cmd/gvpr/lib/topon

raw
1 /* Generate copy of topology of input graph
2 * Replace names with numbers
3 */
4 BEGIN {
5 int id = 0;
6 char* names[char*];
7
8 char* mapn (char* inname)
9 {
10 char* s = names[inname];
11 if (s == "") {
12 s = id++;
13 names[inname] = s;
14 }
15 return s;
16 }
17
18 }
19
20 BEG_G {
21 graph_t g = graph ($.name, "U");
22 }
23 N { node (g, mapn($.name)); }
24 E { edge (node (g, mapn($.tail.name)), node (g, mapn($.head.name)), ""); }
25 END_G {
26 write (g);
27 }