Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: ted [...] tedcarnahan.com
Cc:
AdminCc:

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



Subject: next_successor unavailable in Traversal (PATCH)
Though the documentation mentions it briefly, it is currently (as of Graph-0.80) impossible to use the next_successor parameter when creating a new Graph::Traversal::* object (it dies with "unknown attribute"). The attached patch enables, documents, and tests this feature. Thanks! - Ted Carnahan
Subject: Graph-0.80-next_successor.patch
diff -r Graph-0.80/lib/Graph/Traversal.pm Graph-0.80-mod/lib/Graph/Traversal.pm 147c147 < next_root next_alphabetic next_numeric next_random --- > next_root next_alphabetic next_numeric next_random next_successor 566a567,573 > =item next_successor > > Called when choosing the next vertex to visit. Called with arguments > ($self, $next) where $next is a hash reference with the possible > next vertices as keys. Use this to provide a custom ordering for > choosing vertices, as opposed to C<next_numeric> or C<next_alphabetic>. > diff -r Graph-0.80/t/59_dfs.t Graph-0.80-mod/t/59_dfs.t 1c1 < use Test::More tests => 253; --- > use Test::More tests => 272; 625a626,657 > > { > my @pre; > my @post; > my $t = Graph::Traversal::DFS->new($g0, > first_root => 'a', > pre => sub { push @pre, $_[0] }, > post => sub { push @post, $_[0] }, > next_successor => sub { shift; (reverse sort keys %{ $_[0] })[0] }); > my @t0 = $t->preorder; > my @t1 = $t->postorder; > my @t2 = $t->postorder; > > simple($g1, @t0); > simple($g1, @t1); > simple($g1, @t2); > > is("@pre", "a e f b d c", "pre"); > is("@post", "f e d c b a", "post"); > is("@t0", "@pre", "t0"); > is("@t1", "@post", "t1"); > is("@t2", "@post", "t2"); > > is($t->unseen, 0, "unseen none"); > is($t->seen, 6, "seen all"); > is($t->seeing, 0, "seeing none"); > is("@{[sort $t->seen]}", "a b c d e f", "seen all"); > is("@{[$t->roots]}", "a", "roots"); > ok( $t->is_root('a') ); > ok(!$t->is_root('b') ); > ok(!$t->is_root('c') ); > } diff -r Graph-0.80/t/60_bfs.t Graph-0.80-mod/t/60_bfs.t 1c1 < use Test::More tests => 77; --- > use Test::More tests => 93; 178a179,206 > { > my @pre; > my @post; > my $t = Graph::Traversal::BFS->new($g0, > first_root => 'a', > pre => sub { push @pre, $_[0] }, > post => sub { push @post, $_[0] }, > next_successor => sub { shift; (reverse sort keys %{ $_[0] })[0] }); > my @t0 = $t->preorder; > my @t1 = $t->postorder; > my @t2 = $t->bfs; > > simple($g1, @t0); > simple($g1, @t1); > simple($g1, @t2); > > is("@pre", "a e b f d c", "pre"); > is("@post", "a e b f d c", "post"); > is("@t0", "@pre", "t0"); > is("@t1", "@post", "t1"); > is("@t2", "@post", "t2"); > > is($t->unseen, 0, "unseen none"); > is($t->seen, 6, "seen all"); > is($t->seeing, 0, "seeing none"); > is("@{[sort $t->seen]}", "a b c d e f", "seen all"); > is("@{[$t->roots]}", "a", "roots"); > }
Subject: Re: [rt.cpan.org #24417] next_successor unavailable in Traversal (PATCH)
Date: Mon, 22 Jan 2007 20:58:13 -0500
To: bug-Graph [...] rt.cpan.org
From: Jarkko Hietaniemi <jhi [...] iki.fi>
Ted Carnahan via RT wrote: Show quoted text
> Wed Jan 17 11:04:59 2007: Request 24417 was acted upon. > Transaction: Ticket created by tedcarnahan > Queue: Graph > Subject: next_successor unavailable in Traversal (PATCH) > Broken in: 0.80 > Severity: Normal > Owner: Nobody > Requestors: ted@tedcarnahan.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=24417 > > > > Though the documentation mentions it briefly, it is currently (as of > Graph-0.80) impossible to use the next_successor parameter when creating > a new Graph::Traversal::* object (it dies with "unknown attribute"). > The attached patch enables, documents, and tests this feature. Thanks! > > - Ted Carnahan
Graph 0.81 has been released with this patch.
Graph 0.81 includes this patch.