From 6fb805a7ab10b570bcd699c87e6137c3e330ff50 Mon Sep 17 00:00:00 2001 From: Walt Mankowski Date: Fri, 20 Jul 2007 18:22:12 +0000 Subject: [PATCH] fixed bug in max_flow() -- need to dereference $path to see if it's empty --- MaxFlow.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MaxFlow.pm b/MaxFlow.pm index 6436b8e..c8f0e31 100644 --- a/MaxFlow.pm +++ b/MaxFlow.pm @@ -17,11 +17,10 @@ use warnings; # really edmonds-karp since I'm finding the shortest path from s to t # each time sub max_flow { - my $g = shift; + my ($g, $source, $sink) = @_; my $result = $g->deep_copy_graph; - while (1) { - my $path = shortest_path($result, "s", "t"); + while (my $path = shortest_path($result, $source, $sink)) { last unless @$path; print "path = @$path\n";