0 | |
use Test::More tests => 227;
|
|
0 |
use Test::More tests => 231;
|
1 | 1 |
|
2 | 2 |
use Graph::Directed;
|
3 | 3 |
use Graph::Undirected;
|
|
314 | 314 |
|
315 | 315 |
is($t0, $t0tcfw);
|
316 | 316 |
|
317 | |
my $t3apspfw = Graph::APSP_Floyd_Warshall($g3);
|
|
317 |
my $t3apspfw = $g3->APSP_Floyd_Warshall;
|
318 | 318 |
|
319 | 319 |
is($t3, $t3apspfw);
|
320 | 320 |
|
|
398 | 398 |
is ("@{[sort $tc2->path_vertices(0,1)]}", "0 1");
|
399 | 399 |
is ("@{[sort $tc2->path_vertices(0,2)]}", "0 1 2");
|
400 | 400 |
is ("@{[sort $tc2->path_vertices(1,2)]}", "1 2");
|
401 | |
|
402 | |
}
|
|
401 |
}
|
|
402 |
|
|
403 |
{
|
|
404 |
# From Jon Freeman.
|
|
405 |
my @example = ( [ 1, 3, -2 ],
|
|
406 |
[ 3, 4, 2 ],
|
|
407 |
[ 4, 2, -1 ],
|
|
408 |
[ 2, 1, 4 ],
|
|
409 |
[ 2, 3, 3 ] );
|
|
410 |
my $g = Graph::Directed->new;
|
|
411 |
$g->add_weighted_edge(@$_) for @example;
|
|
412 |
my $apsp = $g->APSP_Floyd_Warshall();
|
|
413 |
# The output from APSP_Floyd_Warshall was non-deterministically
|
|
414 |
# incorrect for two of the possible vertex pairs due to an "|| 1"
|
|
415 |
# instead of defined-or across the 1-3-4 path which had "distance" 2+-2=0
|
|
416 |
my @bad_edges = ( [1, 2, -1, [1,3,4,2]], [2, 4, 4, [2,1,3,4]] );
|
|
417 |
foreach my $e (@bad_edges) {
|
|
418 |
my ($u, $v, $length, $path) = @$e;
|
|
419 |
my @spvs = $apsp->path_vertices($u, $v);
|
|
420 |
is_deeply \@spvs, $path, "APSP $u $v" or diag explain \@spvs;
|
|
421 |
is $apsp->path_length($u, $v), $length, "length $u $v";
|
|
422 |
}
|
|
423 |
}
|