CC: | <jhi [...] iki.fi> |
Subject: | Bugreport: Graph::Undirected, unionfind and connected_components |
Date: | Thu, 29 Nov 2007 14:03:32 +0100 |
To: | <bug-Graph [...] rt.cpan.org> |
From: | "Denis Lagno" <dlagno [...] nvidia.com> |
Hi Jarkko
I detected bug in Graph-0.81 and it reproduces in Graph-0.84
I use perl 5.8.8
If graph is created in unionfind mode it does not correctly handle
adding already existing vertex.
For this test code:
use Graph::Undirected;
sub fill_graph
{
my $graph = shift;
$graph->add_edge('A', 'B');
$graph->add_vertex('A');
}
my $graph1 = Graph::Undirected->new('unionfind' => 1);
fill_graph($graph1);
warn "number of components in unionfind graph is " .
scalar($graph1->connected_components()) . "\n";
my $graph2 = Graph::Undirected->new('unionfind' => 0);
fill_graph($graph2);
warn "number of components in non-unionfind graph is " .
scalar($graph2->connected_components()) . "\n";
It outputs:
number of components in unionfind graph is 2
number of components in non-unionfind graph is 1
I guess it is a bug.
-- denis
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------