aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2017-10-07 23:21:45 +0200
committerSimon Tatham <anakin@pobox.com>2017-10-07 22:36:49 +0100
commit00e23909f8599686ae8aa975a7f5a443a500516f (patch)
tree853db292cb8f31c6c25c10e0a8f748d9778792c3
parentf6b2f47ef3feca86b0d16c28b607acdea5fc6235 (diff)
downloadpuzzles-00e23909f8599686ae8aa975a7f5a443a500516f.zip
puzzles-00e23909f8599686ae8aa975a7f5a443a500516f.tar.gz
puzzles-00e23909f8599686ae8aa975a7f5a443a500516f.tar.bz2
puzzles-00e23909f8599686ae8aa975a7f5a443a500516f.tar.xz
fix loop condition
prev[sink] == 0 means there was a path found with the last step being a forward edge to the sink, and the edge being at index 0 in the array. This is a valid path (the same as any other path indicated by prev[sink] > 0).
-rw-r--r--maxflow.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/maxflow.c b/maxflow.c
index 028946b..97ae8c4 100644
--- a/maxflow.c
+++ b/maxflow.c
@@ -80,7 +80,7 @@ int maxflow_with_scratch(void *scratch, int nv, int source, int sink,
/*
* Now do the BFS loop.
*/
- while (head < tail && prev[sink] <= 0) {
+ while (head < tail && prev[sink] < 0) {
from = todo[head++];
/*