File: BFS.pm

package info (click to toggle)
libgraph-perl 0.20102-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 184 kB
  • ctags: 132
  • sloc: perl: 1,455; makefile: 38
file content (63 lines) | stat: -rw-r--r-- 852 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Graph::BFS;

use strict;
local $^W = 1;

use Graph::Traversal;

use vars qw(@ISA);
@ISA = qw(Graph::Traversal);

=head1 NAME

Graph::BFS - graph breadth-first search

=head1 SYNOPSIS

    use Graph::BFS;

=head1 DESCRIPTION

=over 4

=cut

=pod

=item new

	$bfs = Graph::BFS->new($G, %param)

Returns a new breadth-first search object for the graph $G
and the (optional) parameters %param.

=cut

sub new {
    my $class = shift;
    my $graph = shift;

    Graph::Traversal::new( $class,
			   $graph,
			   current =>
		           sub { $_[0]->{ active_list }->[ 0 ] },
			   finish  =>
		           sub { shift @{ $_[0]->{ active_list } } },
			   @_);
}

=pod

=back

See also C<Graph::Traversal>.

=head1 COPYRIGHT

Copyright 1999, O'Reilly & Associates.

This code is distributed under the same copyright terms as Perl itself.

=cut

1;