in reply to Re^4: How do I use Graph::Traversal?
in thread How do I use Graph::Traversal?

#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Graph; use Graph::Traversal::DFS; my $g = Graph->new(); $graph->add_edges ( ['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'K'], [' +D', 'Z'], ['K', 'R'] ); =some Path 1: A -> B -> C -> D -> K -> R Path 2: A -> B -> C -> D -> Z =cut my $t = Graph::Traversal::DFS->new($g); my @v = $t->preorder; print qq[Preorder:\n]; print qq[$_\t] foreach @v; print qq[\n]; @v = $t->postorder; print qq[Postorder:\n]; print qq[$_\t] foreach @v; print qq[\n]; my @r = $t->roots; print qq[Roots:\n]; print qq[$_\t] foreach @r; print qq[\n];