chiark / gitweb /
fix loop condition
authorStefan Bühler <stbuehler@web.de>
Sat, 7 Oct 2017 21:21:45 +0000 (23:21 +0200)
committerSimon Tatham <anakin@pobox.com>
Sat, 7 Oct 2017 21:36:49 +0000 (22:36 +0100)
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).

maxflow.c

index 028946b9bd400b10eef95a76b4bd6c6c6e377ad6..97ae8c487d469fa74734fbe59545c4a9da4a2a07 100644 (file)
--- 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++];
 
            /*