Pattern
Maximum Flow / Minimum Cut
Push flow along augmenting paths in a residual graph; max flow equals min cut, which models assignment, disjoint paths, and separation problems.
Learn firstGraph BFS / DFS
0%
mastery
0/8 solved
0/8 solved
Recognise it
The signal
capacities on edges, maximise throughput
1Brute force
Enumerate edge subsets for cuts.
2The observation
Exponential cut choices: augmenting paths with reverse edges let flow be rerouted.
3Why it works
Flow is optimal iff no augmenting path exists in the residual graph.
Reach for it when
- +edge-disjoint / vertex-disjoint paths
- +cheapest set of edges to cut s from t
Not when
- ×huge graphs typical of interviews (rarely asked in interviews; mostly CP)
- ×costs on edges (min-cost flow)
Practice
0/8 solved
- Parcel DeliveryCSESHard
- Build StringCodeforces2000
- School DanceCSESHard
- Download SpeedCSESHard
- Police ChaseCSESHard
- Distinct RoutesCSESHard
- Soldier and TravelingCodeforces2100
- Petya and GraphCodeforces2400
Pitfalls
Misconceptions
- !forgetting reverse residual edges
Go deepervariants and techniques · 2 combinations · resources
Variants and techniques
- Bipartite MatchingFind the largest set of disjoint left-right pairs via augmenting paths (Kuhn) or flow; Hungarian for weighted assignment.
- Minimum-Cost Flow (and the assignment problem)CP 2000Augment along cheapest paths: Bellman-Ford/SPFA once, then Dijkstra with Johnson potentials. This gives the minimum total cost for each flow value. Weighted bipartite assignment is the special case that the Hungarian algorithm solves in O(n^3).
Combinations
Maximum Flow / Minimum Cut+Bipartite Matching
pair two groups under compatibility constraints
- Maximum Flow / Minimum Cut:
- the solver (unit capacities)
- Bipartite Matching:
- the model (left-right compatibility)
Minimum-Cost Flow (and the assignment problem)+Bipartite Matching
assign n employees to n tasks with a cost matrix, minimising the total
- Minimum-Cost Flow (and the assignment problem):
- minimises total cost over perfect matchings (Hungarian for dense n x n)
- Bipartite Matching:
- the left/right assignment structure