Subject: | Graph-0.91: bug in unionfind parameter |
Hello,
I probably found a bug in "unionfind". If You create Graph object
with:
my $g = Graph->new( undirected => 1, unionfind => 0 );
all works fine, but if You create it with:
my $g = Graph->new( undirected => 1, unionfind => 1 );
a method "is_connected" always will return TRUE. A simple example of
this situation is in a file in an attachment.
Ps. I've tested this only on Perl v5.10.0 built for x86_64-linux-gnu-
thread-multi.
Thanks for your thoughts on this,
Lukasz Strzelecki
Subject: | graph.pl |
#!/usr/bin/perl
use warnings;
use strict;
use Graph;
# ERROR ================================================================
sub check {
my ($g) = @_;
$g->add_edge( 'a', 'b' );
$g->add_edge( 'b', 'c' );
$g->add_edge( 'c', 'd' );
print $g, "\n";
$g->delete_vertex( 'c' );
print $g, "\n";
if($g->is_connected){ print "Graph is connected!\n"; }
else{ print "Graph is NOT connected!\n"; }
return 0;
}
# ERROR ================================================================
my $g1 = Graph->new( undirected => 1, unionfind => 1 );
check($g1);
print "-" x 72, "\n";
# All OK ===============================================================
my $g2 = Graph->new( undirected => 1, unionfind => 0 );
check($g2);