From 00e23909f8599686ae8aa975a7f5a443a500516f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 7 Oct 2017 23:21:45 +0200 Subject: [PATCH] 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). --- maxflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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++]; /*