From 8119f6d1e4bb0f5ded46a527f4cbd8aea4610c1b Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 15 Dec 2008 04:54:14 -0500 Subject: reorganize the module a bit --- lib/Graph/Implicit.pm | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/Graph/Implicit.pm b/lib/Graph/Implicit.pm index 49935dd..8c8c608 100644 --- a/lib/Graph/Implicit.pm +++ b/lib/Graph/Implicit.pm @@ -44,27 +44,6 @@ sub neighbors { return map { $$_[0] } $self->($from); } -# more complicated graph properties - -sub is_bipartite { - my $self = shift; - my ($from) = @_; - my $ret = 1; - BIPARTITE: { - my %colors = ($from => 0); - no warnings 'exiting'; - $self->bfs($from, sub { - my $vertex = $_[1]; - apply { - last BIPARTITE if $colors{$vertex} == $colors{$_}; - $colors{$_} = not $colors{$vertex}; - } $self->neighbors($vertex) - }); - return 1; - } - return 0; -} - # traversal sub _traversal { @@ -180,7 +159,28 @@ sub johnson { sub floyd_warshall { } -# other (?) +# non-trivial graph properties + +sub is_bipartite { + my $self = shift; + my ($from) = @_; + my $ret = 1; + BIPARTITE: { + my %colors = ($from => 0); + no warnings 'exiting'; + $self->bfs($from, sub { + my $vertex = $_[1]; + apply { + last BIPARTITE if $colors{$vertex} == $colors{$_}; + $colors{$_} = not $colors{$vertex}; + } $self->neighbors($vertex) + }); + return 1; + } + return 0; +} + +# sorting sub topological_sort { } -- cgit v1.2.3