Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: How do I use Graph::Traversal?

by Anonymous Monk
on Aug 08, 2016 at 04:07 UTC ( [id://1169322]=note: print w/replies, xml ) Need Help??


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

Can you post runnable code?

Replies are listed 'Best First'.
Re^5: How do I use Graph::Traversal?
by Anonymous Monk on Aug 08, 2016 at 15:29 UTC
    #!/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];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1169322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found