diff options
author | doy <doy@tozt.net> | 2008-12-14 17:07:51 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-14 17:07:51 -0500 |
commit | 63f7f895888b0bde7c60f1d5cd18399acec161f2 (patch) | |
tree | 488ce1f92c71a7e3c0ab4cb17ad8f99259670277 | |
parent | 625878974ec9f69997de6449aacc727262d0c43a (diff) | |
download | graph-implicit-63f7f895888b0bde7c60f1d5cd18399acec161f2.tar.gz graph-implicit-63f7f895888b0bde7c60f1d5cd18399acec161f2.zip |
factor out neighbor calculation into a method
-rw-r--r-- | lib/Graph/Implicit.pm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Graph/Implicit.pm b/lib/Graph/Implicit.pm index 26f4f5c..828c67f 100644 --- a/lib/Graph/Implicit.pm +++ b/lib/Graph/Implicit.pm @@ -28,6 +28,9 @@ sub edges { } sub neighbors { + my $self = shift; + my ($from) = @_; + return $self->($from); } # traversal @@ -73,7 +76,7 @@ sub dijkstra { ($max_vert, $max_score) = ($vertex, $score) if ($score > $max_score); } - $neighbors{$vertex} = [$self->($vertex)] + $neighbors{$vertex} = [$self->neighbors($vertex)] unless exists $neighbors{$vertex}; for my $neighbor (@{ $neighbors{$vertex} }) { my ($vert_n, $weight_n) = @{ $neighbor }; |