in reply to Re^2: find all paths of length n in a graph
in thread find all paths of length n in a graph
Homework?sub find_path { my ($start_at, $end_at, $been_there) = (@_, {}); if ($start_at == $end_at) { return [$start_at]; } else { my @try_these = grep { ! $been_there->{$_} } @{$adjacency_list{$st +art_at}}; return map { my @cdr_list = find_path($_, $end_at, {%$been_there, $start_at = +> 1}); map [$start_at, @$_], @cdr_list; } @try_these; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: find all paths of length n in a graph
by karden (Novice) on Sep 19, 2007 at 00:54 UTC | |
by Roy Johnson (Monsignor) on Sep 19, 2007 at 15:26 UTC | |
by karden (Novice) on Sep 21, 2007 at 12:12 UTC |