my %winode2island;
my %winode2lines;
my %wiccix2arch;
+my $wialldists;
my $dbdists= Graph::Undirected->new();
my %dbisland2arch;
-my %msgcount;
-sub perr ($$) { print STDERR "$_[0]: $_[1]\n"; $msgcount{$_[0]}++; }
-sub warning ($) { perr("warning",$_[0]); }
-sub error ($) { perr("error", $_[0]); }
-sub change ($) { perr("change", $_[0]); }
+my %msgs;
+sub pmsg ($$) { push @{ $msgs{$_[0]} }, "$_[0]: $_[1]\n"; }
+sub warning ($) { pmsg("warning",$_[0]); }
+sub error ($) { pmsg("error", $_[0]); }
+sub change ($) { pmsg("change", $_[0]); }
+sub print_messages () {
+ foreach my $k (qw(change warning error)) {
+ my $m= $msgs{$k};
+ next unless $m;
+ print sort @$m or die $!;
+ }
+}
if (@ARGV && $ARGV[0] eq '--debug') {
shift @ARGV;
# Compute all-pairs-shortest-paths on dist, which is the
# actual distances between all LPs.
#
- my $wialldists= $widists->APSP_Floyd_Warshall();
+ $wialldists= $widists->APSP_Floyd_Warshall();
# Assign archipelago labels to groups of islands
#
}
}
+sub compare_distances () {
+ foreach my $ia (sort keys %dbisland2arch) {
+ my $na= $wiisland2node{$ia};
+ next unless defined $na;
+ foreach my $ib (sort keys %dbisland2arch) {
+ next unless $ia le $ib; # do every pair only once
+ my $nb= $wiisland2node{$ib};
+ next unless defined $nb;
+ my $dbdist= $dbdists->get_edge_weight($ia,$ib);
+ my $widist= $wialldists->path_length($na,$nb);
+ if (!defined $dbdist) {
+ change(sprintf "define distance %2d for %s..%s",
+ $widist, $ia,$ib);
+ } elsif ($dbdist != $widist) {
+ change(sprintf "change distance %2d to %2d for %s..%s",
+ $dbdist, $widist, $ia,$ib);
+ }
+ }
+ }
+}
+
parse_info_serverside();
db_setocean($ocean);
db_connect();
parse_yppedia_map();
parse_database_map();
process_yppedia_graphs();
+
compare_island_lists();
+compare_distances();
+
+print_messages();