Ford-Fulkerson
Summary
Find the max flow of a graph by iteratively augmenting the residual graph
Contents
Problem Setup
Sending supply from vertex s to t
Goal is to maximize amount sent without exceeding capacity
A flow network
is a graph G=(V,E), designated s,t in V, and for each e in E,
capacity
flow along edge e
flow in must equal flow out (conserved)
size of flow is total flow sent
- flow out of s
- flow in to t
size = 12
There’s never a reason to use a cycle
Anti-Parallel Edges
We can simplify the graph by removing anti-parallel edges
Toy Example
Simple Algorithm
Start by initializing the flow to be zero everywhere
Create an available graph based on the input graph and try to find a path from s to t
Send max flow along that path
Repeat until there is no more path from s to t
instead we can create a Residual Graph by adding antiparallel edges to one way edges
Residual Network
For flow network G=(V,E0) with ce for e in E, and fe for e in E.
residual network Gf=(V,Ef)
if then add to Gf with capacity
if then add to Gf with capacity
Ford-Fulkerson Algorithm
- Set fe = 0 for all e in E
- Build residual network Gf for current flow f
- Check for an s-t path in Gf
- If no such path, output f
- Given path P, let cP = min capacity along P in Gf
- Augment f by cP units along P
- For every forward edge, increase flow by this amount
- For every backward edge, decrease flow by this amount
- Repeat
Runtime
O(mC) where C is size of max flow (assuming integer capacities)