Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: onken [...] netcubed.de
Cc:
AdminCc:

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



Subject: recursive successors and predecessors
Hi, I wish to have a method which returns all successors or predecessors. This would be great.
From: onken [...] houseofdesign.de
On So. 23. Mär. 2008, 17:43:44, PERLER wrote: Show quoted text
> Hi, > > I wish to have a method which returns all successors or predecessors. > This would be great.
this one does the job pretty good and looks out for infinite loops: use List::MoreUtils qw(uniq); sub all_successors { my $g = shift; my @succ = @_; foreach my $succ (@succ) { push(@succ, $g->successors($succ)); @succ = uniq @succ; } return @succ; } $g->all_successors(@list); # @list is a list of vertices or just one
Please retry with Graph 0.86.