return $n;
}
-sub parse_yppedia_map () {
+sub yppedia_chart_parse () {
# We don't even bother with tag soup; instead we do line-oriented parsing.
while (<>) {
}
}
-sub parse_database_map () {
+sub database_fetch_ocean () {
my ($row,$sth);
$sth= $dbh->prepare('SELECT islandname, archipelago FROM islands');
$sth->execute();
}
}
-sub process_yppedia_graphs () {
-
+sub yppedia_graphs_prune_boring () {
# Prune the LP database by eliminating boring intermediate vertices
- #
foreach my $delete ($widists->vertices()) {
next if exists $winode2island{$delete};
my @neigh= $widists->neighbours($delete);
next unless @neigh==2;
-# my @aneigh= $wiarchs->has_vertex($delete)
-# ? $wiarchs->neighbours($delete) : ();
-# next unless @aneigh==0 || @aneigh==2;
my $weight= 0;
map { $weight += $widists->get_edge_weight($delete, $_) } @neigh;
$widists->add_weighted_edge(@neigh, $weight);
$widists->delete_vertex($delete);
printf DEBUG "%-5s elide %5s %-5s %2d\n", $delete, @neigh, $weight;
}
+}
+sub yppedia_graphs_check () {
# Check that it's connected.
- #
foreach my $cc ($widists->connected_components()) {
next if 2*@$cc > $widists->vertices();
my $m= "disconnected league point(s):";
}
warning($m);
}
+}
+sub yppedia_archs_sourceinfo () {
# Assign archipelagoes according to the source-info file
- #
foreach my $arch (sort keys %{ $oceans{$ocean} }) {
foreach my $islename (sort keys %{ $oceans{$ocean}{$arch} }) {
my $islenode= $wiisland2node{$islename};
$wiccix2arch{$ccix}= $arch;
}
}
+}
- # Compute all-pairs-shortest-paths on dist, which is the
- # actual distances between all LPs.
- #
- $wialldists= $widists->APSP_Floyd_Warshall();
-
+sub yppedia_archs_chart_labels () {
# Assign archipelago labels to groups of islands
#
foreach my $label (@wiarchlabels) {
$wiccix2arch{$ccix}= $arch;
# print "$ccix $arch ::\n$desc\n";
}
+}
+sub yppedia_archs_fillbynearest() {
# Assign islands not labelled above to archipelagoes.
#
# We do this by, for each connected component (set of islands
}
parse_info_serverside();
+
db_setocean($ocean);
db_connect();
-parse_yppedia_map();
-parse_database_map();
-process_yppedia_graphs();
+database_fetch_ocean();
+
+yppedia_chart_parse();
+yppedia_graphs_prune_boring();
+yppedia_graphs_check();
+yppedia_archs_sourceinfo();
+$wialldists= $widists->APSP_Floyd_Warshall();
+yppedia_archs_chart_labels();
+yppedia_archs_fillbynearest();
compare_island_lists();
compare_distances();