From: Stefan Bühler Date: Sat, 7 Oct 2017 21:21:45 +0000 (+0200) Subject: fix loop condition X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=00e23909f8599686ae8aa975a7f5a443a500516f;p=sgt-puzzles.git 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). --- 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++]; /*