summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-02-07 16:25:26 -0500
committerdoy <doy@tozt.net>2009-02-07 16:25:26 -0500
commit2bde2a6965b9ee52d034bc00046f09fcb3984257 (patch)
tree453faa77a2b11f3c08b59656247dcba048b85026
parent109c0d07d7d2ee792b197dffa8c201ed0d7488d7 (diff)
downloadgraph-implicit-2bde2a6965b9ee52d034bc00046f09fcb3984257.tar.gz
graph-implicit-2bde2a6965b9ee52d034bc00046f09fcb3984257.zip
add failing test - the algo for this fails with either directed graphs or graphs with non-unique edge weights, need to look more into this
-rw-r--r--t/003-minimum-spanning-tree.t10
1 files changed, 6 insertions, 4 deletions
diff --git a/t/003-minimum-spanning-tree.t b/t/003-minimum-spanning-tree.t
index f8192df..9421901 100644
--- a/t/003-minimum-spanning-tree.t
+++ b/t/003-minimum-spanning-tree.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 6;
use Test::Deep;
use Graph::Implicit;
use List::MoreUtils qw/pairwise/;
@@ -57,8 +57,10 @@ my %reachable = (
h => [qw/ f g h/],
);
my %mst = (
- d => {a => 'd', b => 'd', c => 'a', d => undef,
- e => 'c', f => 'b', g => 'h', h => 'd'},
+ a => {a => undef, b => 'd', c => 'a', d => 'e',
+ e => 'c', f => 'b', g => 'h', h => 'd'},
+ d => {a => 'd', b => 'd', c => 'a', d => undef,
+ e => 'c', f => 'b', g => 'h', h => 'd'},
);
my $edge_calculator = sub {
my $vertex = shift;
@@ -67,7 +69,7 @@ my $edge_calculator = sub {
my $graph = Graph::Implicit->new($edge_calculator);
for my $traversal (qw/prim/) {
- for my $vertex (qw/d/) {
+ for my $vertex (keys %mst) {
my @visited;
my $tree = $graph->$traversal($vertex, sub { push @visited, $_[1] });
cmp_bag(\@visited, $reachable{$vertex},