1package Graph::Traversal::BFS;
2
3use strict;
4
5use Graph::Traversal;
6use base 'Graph::Traversal';
7
8sub current {
9    my $self = shift;
10    $self->{ order }->[ 0 ];
11}
12
13sub see {
14    my $self = shift;
15    shift @{ $self->{ order } };
16}
17
18*bfs = \&Graph::Traversal::postorder;
19
201;
21__END__
22=pod
23
24=head1 NAME
25
26Graph::Traversal::BFS - breadth-first traversal of graphs
27
28=head1 SYNOPSIS
29
30    use Graph;
31    my $g = Graph->new;
32    $g->add_edge(...);
33    use Graph::Traversal::BFS;
34    my $b = Graph::Traversal::BFS->new(%opt);
35    $b->bfs; # Do the traversal.
36
37=head1 DESCRIPTION
38
39With this class one can traverse a Graph in breadth-first order.
40
41The callback parameters %opt are explained in L<Graph::Traversal>.
42
43=head2 Methods
44
45The following methods are available:
46
47=over 4
48
49=item dfs
50
51Traverse the graph in depth-first order.
52
53=back
54
55=head1 SEE ALSO
56
57L<Graph::Traversal>, L<Graph::Traversal::DFS>, L<Graph>.
58
59=cut
60