| Graph::Traversal - traverse graphs |
Graph::Traversal - traverse graphs
Don't use Graph::Traversal directly, use Graph::Traversal::DFS or Graph::Traversal::BFS instead.
use Graph;
my $g = Graph->new;
$g->add_edge(...);
use Graph::Traversal::...;
my $t = Graph::Traversal::...->new(%opt);
$t->...
You can control how the graph is traversed by the various callback
parameters in the %opt. In the parameters descriptions below the
$u and $v are vertices, and the $self is the traversal object itself.
The following callback parameters are available:
back_edge, a down_edge, or a cross_edge).
Called with arguments ($u, $v, $self).
undef.
first_root and undefining next_root.
The parameters first_root and next_successor have a 'hierarchy'
of how they are determined: if they have been explicitly defined, use
that value. If not, use the value of next_alphabetic, if that has
been defined. If not, use the value of next_numeric, if that has
been defined. If not, the next vertex to be visited is chose randomly.
The following methods are available:
$v = $t->vertex_by_preorder($i)
Return the ith (0..$V-1) vertex by preorder.
$i = $t->preorder_by_vertex($v)
Return the preorder index (0..$V-1) by vertex.
$v = $t->vertex_by_postorder($i)
Return the ith (0..$V-1) vertex by postorder.
$i = $t->postorder_by_vertex($v)
Return the postorder index (0..$V-1) by vertex.
$t->has_state('s')
Test whether the traversal has state 's' attached to it.
$t->get_state('s')
Get the state 's' attached to the traversal (undef if none).
$t->set_state('s', $s)
Set the state 's' attached to the traversal.
$t->delete_state('s')
Delete the state 's' from the traversal.
The following parameters are for backward compatibility to Graph 0.2xx:
next_root.
tree_edge both non_tree_edge defined
to be the same.
tree_edge.
seed_edge.
If in a callback you call the special terminate method,
the traversal is terminated, no more vertices are traversed.
the Graph::Traversal::DFS manpage, the Graph::Traversal::BFS manpage
Jarkko Hietaniemi jhi@iki.fi
This module is licensed under the same terms as Perl itself.
| Graph::Traversal - traverse graphs |