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