From 40f5e6b637d854f644916adb0ba863fe2628ab6f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Sep 2009 13:28:38 +0100 Subject: [PATCH] Render topology as input to neato. --- yarrg/ocean-topology-graph | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 yarrg/ocean-topology-graph diff --git a/yarrg/ocean-topology-graph b/yarrg/ocean-topology-graph new file mode 100755 index 0000000..55d15d9 --- /dev/null +++ b/yarrg/ocean-topology-graph @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +use strict (qw(vars)); + +use CommodsDatabase; + +my $ocean= shift @ARGV; + +db_setocean($ocean); +db_connect(); +my $islands= $dbh->selectall_arrayref(' + SELECT islandid,islandname FROM islands; +'); +my $routes= $dbh->selectall_arrayref(' + SELECT aiid, biid, dist FROM routes; +'); +$dbh->disconnect(); + +#use Data::Dumper; +#print Dumper($results); + +print "strict graph $ocean {\n"; +#print " nodesep=10;\n"; + +foreach my $row (@$islands) { + my ($id,$str) = @$row; + $str =~ s/[\"\\]/\\$&/g; + print " n$id [ label=\"$str\" ];\n"; +} +foreach my $row (@$routes) { + my ($ia,$ib,$dist) = @$row; + print " n$ia -- n$ib [ len=2, label=$dist ];\n"; + #len=$dist, minlen=$dist, weight=".(1.0/$dist).", len=".($dist*0.25+1).", + #w=".(1.0/$dist).", +} + +print "}\n"; -- 2.30.2