Network Flow

Max flow, min cut, and the Ford-Fulkerson algorithm

Network Flow

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.

Flow theory connects graph structure to optimization: the Ford-Fulkerson algorithm finds maximum flow by iteratively discovering augmenting paths, while the max-flow min-cut theorem reveals a deep duality between flow and connectivity.

Flow Network Basics

A flow network is a directed graph where each edge has a capacity. Flow travels from a source to a sink, obeying capacity constraints and conservation laws. Click edges to adjust flow and observe how the constraints interact.

Click an edge to select it, then use controls below to adjust flow

0
Total Flow
Valid
Conservation
Valid
Capacity
Source
Sink
Intermediate
Saturated

Key insight: A valid flow must satisfy two constraints at every node: capacity (flow cannot exceed edge capacity) and conservation (flow in equals flow out at intermediate nodes).

Ford-Fulkerson Algorithm

The Ford-Fulkerson algorithm finds maximum flow by repeatedly discovering augmenting paths from source to sink in the residual graph and pushing flow along them. This implementation uses BFS (Edmonds-Karp variant), guaranteeing O(VE^2) time.

Iteration: 0Phase: Ready
0
Current Flow
0
Iterations
Running...
Status
Speed:Med

Key insight: The residual graph includes backward edges that allow the algorithm to “undo” previous flow decisions, ensuring it always converges to the global optimum.

Max-Flow Min-Cut Theorem

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 partitions vertices into two sets, with the source in one and the sink in the other.

0
Max Flow
?
Min Cut Capacity

Key insight: This duality between flow and cuts is a cornerstone of combinatorial optimization — the bottleneck of any network is determined by its weakest separating boundary.

Bipartite Matching via Flow

Maximum bipartite matching reduces to a max-flow problem: connect a source to one partition, the other partition to a sink, and set all capacities to 1. The maximum flow equals the size of the largest matching.

Green edges = matched pairs in optimal solution

Toggle Qualifications (click to enable/disable):
0
Maximum Matching
9
Possible Edges

Key insight: Reducing matching to flow demonstrates the power of network flow as a general framework — many optimization problems on bipartite structures can be solved this way.

Key Takeaways

  • Flow networks — directed graphs with capacities, a source producing flow, and a sink consuming it
  • Ford-Fulkerson — finds max flow by augmenting paths in the residual graph; Edmonds-Karp uses BFS for O(VE^2) time
  • Max-flow min-cut — maximum flow equals the minimum cut capacity, connecting flow to graph connectivity
  • Bipartite matching — reduces to max flow with unit capacities, solving assignment and allocation problems