Mercurial > hg > anonet-resdb
view doc/ucis.ano/bgp_graph/path_list_to_dot.php @ 28:4dbe5bf653bb draft
Added bgp graph scripts
author | ivo <ivo@UFO-Net.nl> |
---|---|
date | Thu, 10 Jun 2010 00:15:51 +0200 |
parents | |
children | 6e8078af6baf |
line wrap: on
line source
#!/usr/bin/php <?php $nodes = array(); $file = STDIN; while (!feof($file)) { $line = stream_get_line($file, 1024, "\n"); if ($line === NULL) break; if (!strlen($line)) continue; $pathnodes = explode(' ', $line); $prevnode = NULL; foreach ($pathnodes as $node) { if ($prevnode && $node) $nodes[$prevnode][$node] = 1; $prevnode = $node; } } foreach ($nodes as $node => $links) { foreach ($links as $link => $dummy) { if (isset($nodes[$node][$link]) && isset($nodes[$link][$node])) unset($nodes[$link][$node]); } } print("graph BGP_nodes {\n"); foreach ($nodes as $node => $links) { foreach ($links as $link => $dummy) { print("\t".$node.' -- '.$link.";\n"); } } print('}');