.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Graph::Traversal 3pm" .TH Graph::Traversal 3pm "2013-05-24" "perl v5.18.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Graph::Traversal \- traverse graphs .SH "SYNOPSIS" .IX Header "SYNOPSIS" Don't use Graph::Traversal directly, use Graph::Traversal::DFS or Graph::Traversal::BFS instead. .PP .Vb 6 \& use Graph; \& my $g = Graph\->new; \& $g\->add_edge(...); \& use Graph::Traversal::...; \& my $t = Graph::Traversal::...\->new($g, %opt); \& $t\->... .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" You can control how the graph is traversed by the various callback parameters in the \f(CW%opt\fR. In the parameters descriptions below the \&\f(CW$u\fR and \f(CW$v\fR are vertices, and the \f(CW$self\fR is the traversal object itself. .SS "Callback parameters" .IX Subsection "Callback parameters" The following callback parameters are available: .IP "tree_edge" 4 .IX Item "tree_edge" Called when traversing an edge that belongs to the traversal tree. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "non_tree_edge" 4 .IX Item "non_tree_edge" Called when an edge is met which either leads back to the traversal tree (either a \f(CW\*(C`back_edge\*(C'\fR, a \f(CW\*(C`down_edge\*(C'\fR, or a \f(CW\*(C`cross_edge\*(C'\fR). Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "pre_edge" 4 .IX Item "pre_edge" Called for edges in preorder. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "post_edge" 4 .IX Item "post_edge" Called for edges in postorder. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "back_edge" 4 .IX Item "back_edge" Called for back edges. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "down_edge" 4 .IX Item "down_edge" Called for down edges. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "cross_edge" 4 .IX Item "cross_edge" Called for cross edges. Called with arguments ($u, \f(CW$v\fR, \f(CW$self\fR). .IP "pre" 4 .IX Item "pre" .PD 0 .IP "pre_vertex" 4 .IX Item "pre_vertex" .PD Called for vertices in preorder. Called with arguments ($v, \f(CW$self\fR). .IP "post" 4 .IX Item "post" .PD 0 .IP "post_vertex" 4 .IX Item "post_vertex" .PD Called for vertices in postorder. Called with arguments ($v, \f(CW$self\fR). .IP "first_root" 4 .IX Item "first_root" Called when choosing the first root (start) vertex for traversal. Called with arguments ($self, \f(CW$unseen\fR) where \f(CW$unseen\fR is a hash reference with the unseen vertices as keys. .IP "next_root" 4 .IX Item "next_root" Called when choosing the next root (after the first one) vertex for traversal (useful when the graph is not connected). Called with arguments ($self, \f(CW$unseen\fR) where \f(CW$unseen\fR is a hash reference with the unseen vertices as keys. If you want only the first reachable subgraph to be processed, set the next_root to \f(CW\*(C`undef\*(C'\fR. .IP "start" 4 .IX Item "start" Identical to defining \f(CW\*(C`first_root\*(C'\fR and undefining \f(CW\*(C`next_root\*(C'\fR. .IP "next_alphabetic" 4 .IX Item "next_alphabetic" Set this to true if you want the vertices to be processed in alphabetic order (and leave first_root/next_root undefined). .IP "next_numeric" 4 .IX Item "next_numeric" Set this to true if you want the vertices to be processed in numeric order (and leave first_root/next_root undefined). .IP "next_successor" 4 .IX Item "next_successor" Called when choosing the next vertex to visit. Called with arguments ($self, \f(CW$next\fR) where \f(CW$next\fR is a hash reference with the possible next vertices as keys. Use this to provide a custom ordering for choosing vertices, as opposed to \f(CW\*(C`next_numeric\*(C'\fR or \f(CW\*(C`next_alphabetic\*(C'\fR. .PP The parameters \f(CW\*(C`first_root\*(C'\fR and \f(CW\*(C`next_successor\*(C'\fR have a 'hierarchy' of how they are determined: if they have been explicitly defined, use that value. If not, use the value of \f(CW\*(C`next_alphabetic\*(C'\fR, if that has been defined. If not, use the value of \f(CW\*(C`next_numeric\*(C'\fR, if that has been defined. If not, the next vertex to be visited is chose randomly. .SS "Methods" .IX Subsection "Methods" The following methods are available: .IP "unseen" 4 .IX Item "unseen" Return the unseen vertices in random order. .IP "seen" 4 .IX Item "seen" Return the seen vertices in random order. .IP "seeing" 4 .IX Item "seeing" Return the active fringe vertices in random order. .IP "preorder" 4 .IX Item "preorder" Return the vertices in preorder traversal order. .IP "postorder" 4 .IX Item "postorder" Return the vertices in postorder traversal order. .IP "vertex_by_preorder" 4 .IX Item "vertex_by_preorder" .Vb 1 \& $v = $t\->vertex_by_preorder($i) .Ve .Sp Return the ith (0..$V\-1) vertex by preorder. .IP "preorder_by_vertex" 4 .IX Item "preorder_by_vertex" .Vb 1 \& $i = $t\->preorder_by_vertex($v) .Ve .Sp Return the preorder index (0..$V\-1) by vertex. .IP "vertex_by_postorder" 4 .IX Item "vertex_by_postorder" .Vb 1 \& $v = $t\->vertex_by_postorder($i) .Ve .Sp Return the ith (0..$V\-1) vertex by postorder. .IP "postorder_by_vertex" 4 .IX Item "postorder_by_vertex" .Vb 1 \& $i = $t\->postorder_by_vertex($v) .Ve .Sp Return the postorder index (0..$V\-1) by vertex. .IP "preorder_vertices" 4 .IX Item "preorder_vertices" Return a hash with the vertices as the keys and their preorder indices as the values. .IP "postorder_vertices" 4 .IX Item "postorder_vertices" Return a hash with the vertices as the keys and their postorder indices as the values. .IP "tree" 4 .IX Item "tree" Return the traversal tree as a graph. .IP "has_state" 4 .IX Item "has_state" .Vb 1 \& $t\->has_state(\*(Aqs\*(Aq) .Ve .Sp Test whether the traversal has state 's' attached to it. .IP "get_state" 4 .IX Item "get_state" .Vb 1 \& $t\->get_state(\*(Aqs\*(Aq) .Ve .Sp Get the state 's' attached to the traversal (\f(CW\*(C`undef\*(C'\fR if none). .IP "set_state" 4 .IX Item "set_state" .Vb 1 \& $t\->set_state(\*(Aqs\*(Aq, $s) .Ve .Sp Set the state 's' attached to the traversal. .IP "delete_state" 4 .IX Item "delete_state" .Vb 1 \& $t\->delete_state(\*(Aqs\*(Aq) .Ve .Sp Delete the state 's' from the traversal. .SS "Backward compatibility" .IX Subsection "Backward compatibility" The following parameters are for backward compatibility to Graph 0.2xx: .IP "get_next_root" 4 .IX Item "get_next_root" Like \f(CW\*(C`next_root\*(C'\fR. .IP "successor" 4 .IX Item "successor" Identical to having \f(CW\*(C`tree_edge\*(C'\fR both \f(CW\*(C`non_tree_edge\*(C'\fR defined to be the same. .IP "unseen_successor" 4 .IX Item "unseen_successor" Like \f(CW\*(C`tree_edge\*(C'\fR. .IP "seen_successor" 4 .IX Item "seen_successor" Like \f(CW\*(C`seed_edge\*(C'\fR. .SS "Special callbacks" .IX Subsection "Special callbacks" If in a callback you call the special \f(CW\*(C`terminate\*(C'\fR method, the traversal is terminated, no more vertices are traversed. .SH "SEE ALSO" .IX Header "SEE ALSO" Graph::Traversal::DFS, Graph::Traversal::BFS .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" Jarkko Hietaniemi \fIjhi@iki.fi\fR .SH "LICENSE" .IX Header "LICENSE" This module is licensed under the same terms as Perl itself.