thor has asked for the wisdom of the Perl Monks concerning the following question:
Greetings fellow monks,
I find myself in a situation where I have a data set that's well represented by a Graph. Knowing that CPAN has Graph, I use it. I now want to traverse the graph, but I'm finding the results are not what I expect. Here's a test script:
I realize that the algorithm is non-deterministic, but it should at least return the correct result. I'd expect that it'd print 'A' and then all the capital letters followed by all the lower-case letters, or vice versa. The docs are unusually sparse. Am I missing something here?use strict; use warnings; use Graph; use Graph::Traversal::DFS; my $graph = Graph->new(); $graph->add_edges( ['A','B'], ['B','C'], ['C','D'], ['D','E'], ['A','b'], ['b','c'], ['c','d'], ['d','e']); my $trav = Graph::Traversal::DFS->new($graph); print join("\n", $trav->dfs()); __END__ E D e d c b C B A
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I use Graph::Traversal?
by runrig (Abbot) on Jul 06, 2005 at 23:34 UTC | |
by thor (Priest) on Jul 07, 2005 at 02:54 UTC | |
by runrig (Abbot) on Jul 07, 2005 at 16:40 UTC | |
by thor (Priest) on Jul 07, 2005 at 18:17 UTC | |
Re: How do I use Graph::Traversal?
by Joost (Canon) on Jul 07, 2005 at 00:05 UTC | |
by melmoth (Acolyte) on Aug 08, 2016 at 00:57 UTC | |
by Anonymous Monk on Aug 08, 2016 at 02:35 UTC | |
by Anonymous Monk on Aug 08, 2016 at 22:08 UTC | |
by melmoth (Acolyte) on Aug 09, 2016 at 04:36 UTC | |
| |
by Anonymous Monk on Aug 08, 2016 at 04:07 UTC | |
by Anonymous Monk on Aug 08, 2016 at 15:29 UTC |
Back to
Seekers of Perl Wisdom