X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Focean-topology-graph;fp=yarrg%2Focean-topology-graph;h=55d15d97e8f5b20d530360c1fde16144cbea77f9;hb=40f5e6b637d854f644916adb0ba863fe2628ab6f;hp=0000000000000000000000000000000000000000;hpb=2e5e1c4479f350077245d74a9c82c08590554a22;p=ypp-sc-tools.web-live.git 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";