Mercurial > hg > anonet-resdb
annotate doc/ucis.ano/bgp_graph/path_list_to_dot.php @ 46:c79c2e94307c draft
forgot semicolons in dot code (bug reported and tracked down by UFO)
author | Nick <nick@somerandomnick.ano> |
---|---|
date | Sat, 12 Jun 2010 00:05:16 +0000 |
parents | fd9b90f6fbc1 |
children | f2fb1d2dcf8c |
rev | line source |
---|---|
28 | 1 #!/usr/bin/php |
2 <?php | |
3 $nodes = array(); | |
4 | |
5 $file = STDIN; | |
6 | |
7 while (!feof($file)) { | |
8 $line = stream_get_line($file, 1024, "\n"); | |
9 if ($line === NULL) break; | |
10 if (!strlen($line)) continue; | |
11 $pathnodes = explode(' ', $line); | |
12 $prevnode = NULL; | |
13 foreach ($pathnodes as $node) { | |
14 if ($prevnode && $node) $nodes[$prevnode][$node] = 1; | |
15 $prevnode = $node; | |
16 } | |
17 } | |
18 | |
19 foreach ($nodes as $node => $links) { | |
20 foreach ($links as $link => $dummy) { | |
34 | 21 if ($node != $link && isset($nodes[$node][$link]) && isset($nodes[$link][$node])) unset($nodes[$link][$node]); |
28 | 22 } |
23 } | |
24 | |
35 | 25 function nodename ($node) { switch ($node) { |
37 | 26 case '64731': return 'SRN (AS64731)'; |
27 }; return 'AS'.$node; }; | |
35 | 28 |
29 $nodelist=array(); | |
30 foreach ($nodes as $node => $links) { | |
31 if (!array_key_exists($node,$nodelist)) $nodelist[$node]=nodename($node); | |
32 foreach ($links as $link => $dummy) | |
33 if (!array_key_exists($link,$nodelist)) $nodelist[$node]=nodename($link); | |
34 }; | |
35 | |
36 | 36 print("graph BGP_nodes {\n"); |
35 | 37 foreach ($nodelist as $node => $name) |
46
c79c2e94307c
forgot semicolons in dot code (bug reported and tracked down by UFO)
Nick <nick@somerandomnick.ano>
parents:
37
diff
changeset
|
38 print "\t".$node.' [label="'.$name.'"];'."\n"; |
35 | 39 |
28 | 40 foreach ($nodes as $node => $links) { |
41 foreach ($links as $link => $dummy) { | |
42 print("\t".$node.' -- '.$link.";\n"); | |
43 } | |
44 } | |
45 print('}'); |