diff options
author | doy <doy@tozt.net> | 2008-12-15 04:54:14 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-15 04:54:14 -0500 |
commit | 8119f6d1e4bb0f5ded46a527f4cbd8aea4610c1b (patch) | |
tree | 517798610b8beed39743f6c9a5f0b68af531b02f | |
parent | 0cebe87c6a3f05c0767840993fb6c53faab4c2f0 (diff) | |
download | graph-implicit-8119f6d1e4bb0f5ded46a527f4cbd8aea4610c1b.tar.gz graph-implicit-8119f6d1e4bb0f5ded46a527f4cbd8aea4610c1b.zip |
reorganize the module a bit
-rw-r--r-- | lib/Graph/Implicit.pm | 44 |
1 files 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 { } |