Consider a directed graph with arbitrary vertices and . Thinking of the weight of each edge as a capacity, max flow asks for the maximum amount we can push from (the source) to (the sink). The “liquid in pipes” metaphor is pretty useless, but there are many seemingly difficult problems that are made obvious via a mapping to max-flow.
In later definitions you’ll find references to the “amount” or “how much” of something we can push from to . A natural question asks what exactly is being counted and pushed. The genericness of the capacity and thus the flow is inherited from the unitless nature of edge weights. Our edge weights are unitless integers, so the max flow from to is as well.
Defining flow networks
Along with a directed graph , we have a capacity for each edge , and two vertices and .
A flow for any edge in satisfies:
- the capacity constraint, that .
- conservation, that for nodes besides and , . In other words, the sum of all flows with directed edges to any is equal to that of edges from .
- the amount leaving is equal to the amount entering , that .
The goal of max flow is to maximize flow.
Residual capacities, augmenting paths
Given a flow , define the **residual capacity c_f$:
- Forward room is . It’s how much beyond the flow our capacity would let us push.
- Backward room is . It’s how much we could send backwards in the network for use in a more optimal subpath. All edges with positive form the residual graph , an augmenting path is any -path in .
Let be the minimum residual capacity along an augmenting path. If we add to every forward edge and subtract it from every backward edge, we increase the flow of the network by . In essence, the residual path uses the flow at immediate edges to instruct the -path that maximizes .
Algorithms
Ford-Fulkerson
As long as there’s a way to increase flow (there’s some augmenting path in ), push as much as you safely can onto it. The amount being pushed is inherently . Update the residual capacities and continue. When no augmenting path exists, we’ve reached maximum flow.
Edmonds-Karp
Edmonds-Karp combines Ford-Fulkerson with BFS. FF shows us that there if we build a residual graph, find a augmenting path, increase the network flow by , and repeat until there is no augmenting path, then we’ve reached max flow. EK constructs the residual graph like FF but intelligently chooses the augmenting path with the fewest edges via BFS. Augmenting along this path by and recomputing until no augmenting path exists gives a polynomial bound to the max flow problem.