Max flow, min cut, and the Ford-Fulkerson algorithm
Network flow models the transportation of commodities through a network from a source to a sink. Each edge has a capacity limit, and we want to maximize the total flow while respecting these constraints.
In this section, you'll learn about flow networks, the celebrated Ford-Fulkerson algorithm, the powerful max-flow min-cut theorem, and see how flow theory solves practical problems like job assignment.
A flow network is a directed graph where each edge has a capacity. Flow travels from a source (S) to a sink (T). Click an edge to adjust its flow!
Click an edge to select it, then use controls below to adjust flow
The Ford-Fulkerson algorithm finds the maximum flow by repeatedly finding augmenting paths from source to sink and pushing flow along them. This implementation uses BFS (Edmonds-Karp).
The Max-Flow Min-Cut Theorem states that the maximum flow from source to sink equals the minimum capacity of any cut separating them. A cut divides vertices into two sets (S containing source, T containing sink).
Maximum bipartite matching can be solved using max flow! Model the problem as a flow network: source connects to one set, the other set connects to sink. Each edge has capacity 1.
Assign workers to jobs where each worker can do at most one job and each job needs exactly one worker. Lines show which workers are qualified for which jobs.
Green edges = matched pairs in optimal solution
1. Flow Networks: A directed graph with capacities on edges, a source node producing flow, and a sink node consuming flow. Flow must satisfy capacity constraints and conservation (flow in = flow out at intermediate nodes).
2. Ford-Fulkerson Algorithm: Repeatedly find augmenting paths from source to sink in the residual graph and push flow along them. The Edmonds-Karp variant uses BFS and runs in O(VE²) time.
3. Max-Flow Min-Cut Theorem: The maximum flow from source to sink equals the minimum capacity of any cut separating them. This powerful duality connects flow to graph connectivity.
4. Applications: Maximum bipartite matching reduces to max flow with unit capacities. This models job assignments, resource allocation, and many other real-world optimization problems.
Next Up: In the next section, you'll explore spectral graph theory — using eigenvalues and eigenvectors to uncover hidden structure in graphs!