File: colour_nodes.g

package info (click to toggle)
xdeb 0.6.6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 252 kB
  • sloc: python: 1,638; sh: 28; makefile: 22
file content (27 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BEGIN {node_t n; int deg[]; int maxdeg;
maxdeg =1;}
E{
//$.label = $.weight;
deg[tail] = deg[tail] + $.weight; 
 if(maxdeg < deg[tail])
 {
 	maxdeg = deg[tail];
 }
}
END_G  { 
	string col;
	int rval;
	int scale;
  for (n = fstnode($G); n; n = nxtnode(n)) {
    if (n.shape != "box")
    {
        scale = ((128 / (float)log(maxdeg)) * log(deg[n]));
        col = sprintf("#%02X%02X%02X", scale, 255-scale, scale);
        //n.fillcolor = col;
        n.color = col;
        n.style = "filled";
        n.label = n.name + sprintf(" (%d)", deg[n]);
    }
  }
  $O = $G;
}