Find augmenting paths in a residual network, push each bottleneck, and use reverse edges to reroute flow.
Core idea
A residual network records how much more flow can move forward and how much previous flow can be canceled backward. Each augmenting path pushes its smallest residual capacity.
Read the visualization
Edge labels show flow over capacity. The active path is highlighted before its bottleneck is added, and reverse residual choices preserve the ability to reroute earlier decisions.
Initialize every network edge with zero flow and its full residual capacity.
17constpushed=dfs(s, Infinity, newArray(n).fill(false)); // find one count augmenting path
18if (pushed ===0) break;
19 flow += pushed; // find bottleneck
20 }
21return flow;
22}
source → sinks → t
current flow0 / maximum 6
1 / 10
Complexity and tradeoffs
Time: O(EF) for integer Ford-Fulkerson. Space: O(V+E). The bound depends on maximum flow F; Edmonds-Karp or Dinic gives stronger path-selection guarantees.
Invariant: Every intermediate flow respects edge capacities and conserves flow at all vertices except the source and sink.
Where it fits
Maximum flow solves transport capacity, bipartite matching, image segmentation, and many disjoint-path problems. The final unreachable boundary also identifies a minimum cut.