Technique
Bipartite Matching
Find the largest set of disjoint left-right pairs via augmenting paths (Kuhn) or flow; Hungarian for weighted assignment.
0%
mastery
0/4 solved
0/4 solved
Recognise it
The signal
pair items of two groups by compatibility only (who can go with whom), maximising pairs
1Brute force
Try all matchings.
2The observation
Exponential search: augmenting paths increase matching by one each time.
3Why it works
A matching is maximum iff no augmenting path exists.
Reach for it when
- +minimum vertex cover in a bipartite graph (Konig)
Not when
- ×general (non-bipartite) graphs need blossom
- ×small n with bitmask DP may be simpler
Practice
0/4 solved
- Coin GridCSESMedium
- Task AssignmentCSESHard
- Grid Puzzle IICSESHard
- School DanceCSESHard
Pitfalls
Misconceptions
- !greedy matching (fails)
- !With costs on the pairs (minimise total cost) it's weighted assignment: Hungarian or min-cost flow, not maximum matching.
Looks like it, isn't
- Task Assignment needs Minimum-Cost Flow (and the assignment problem)
Why
Every employee-task pair has a cost and the total is minimised: weighted assignment (Hungarian / MCMF), not max matching. source ↗
Go deeper2 combinations · resources
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