Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

Report information
The Basics
Id: 50210
Status: resolved
Priority: 0/
Queue: Graph

People
Owner: Nobody in particular
Requestors: flagg [...] onet.eu
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.91
Fixed in: (no value)



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);
One cannot delete vertices or edges from a unionfind graph, it's "add-only". I now added code to enforce this.