summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-15 00:49:26 -0500
committerdoy <doy@tozt.net>2008-12-15 00:49:26 -0500
commita918de5eb7145b28dbf6f94044ab0acc7bb6fb0b (patch)
tree81593e806c3b9ab97e41ffd2a2a6028b59570680
parenteca74d7f0782b4db4e065a58d47c6f96774ab6a1 (diff)
downloadgraph-implicit-a918de5eb7145b28dbf6f94044ab0acc7bb6fb0b.tar.gz
graph-implicit-a918de5eb7145b28dbf6f94044ab0acc7bb6fb0b.zip
add a helper function to build up a path from a hash of predecessors
-rw-r--r--lib/Graph/Implicit.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Graph/Implicit.pm b/lib/Graph/Implicit.pm
index ca4f663..6fa42cb 100644
--- a/lib/Graph/Implicit.pm
+++ b/lib/Graph/Implicit.pm
@@ -171,4 +171,16 @@ sub johnson {
sub floyd_warshall {
}
+# misc utility functions
+
+sub make_path {
+ my ($pred, $end) = @_;
+ my @path;
+ while (defined $end) {
+ push @path, $end;
+ $end = $pred->{$end};
+ }
+ return reverse @path;
+}
+
1;