Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: kulp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.84
Fixed in: (no value)



Subject: Inconsistent traversal on even trivial graphs
On two Linux machines with perl 5.8.8 (an AMD Athlon 64 X2 and a Pentium D, though it shouldn't matter), the attached test case shows failures for on average half of the twenty cases in each run. That is, the traversal sometimes fails to traverse any edges at all, and this graph has only one edge! Graph::Traversal::BFS is shown, but the same is true for ::DFS. -- --kulp
Subject: graph-traversal-failure.pl
#!/usr/bin/env perl use strict; use warnings; use Graph; use Graph::Traversal::BFS; print $Graph::VERSION, "\n"; my $ok; my $g = Graph->new; $g->add_edge(0,1); my $sub = sub { warn "@_[0,1]\n"; $ok = 1; }; my $t = Graph::Traversal::BFS->new($g, tree_edge => $sub); for (1 .. 20) { $ok = 0; $t->bfs; $t->reset; print "trial $_ was NOT OK\n" unless $ok; }
From: luben [...] unixsol.org
On Fri Jun 13 13:12:40 2008, KULP wrote: Show quoted text
> On two Linux machines with perl 5.8.8 (an AMD Athlon 64 X2 and a Pentium > D, though it shouldn't matter), the attached test case shows failures > for on average half of the twenty cases in each run. That is, the > traversal sometimes fails to traverse any edges at all, and this graph > has only one edge! > > Graph::Traversal::BFS is shown, but the same is true for ::DFS.
By default Graph->new creates directed graph. In half of the cases it selects the node from which you could not reach the other node because there is no path to it. If you change the like 12 of the example file to be : my $g = Graph->new (undirected =>1); It will run as you expect.