Maximum Bipartite Matching via Flow
A matching in a bipartite graph can be found by reduction to maximum flow. This is one of the cleanest applications of network flow theory and appears frequently on Tripos papers.
Bipartite Matching
A bipartite graph has with and every edge crossing between and : .
A matching is a set of edges such that no vertex is incident to more than one edge in . A vertex is matched if some edge in is incident on it; otherwise it is unmatched.
A maximum matching is a matching of maximum cardinality. A maximal matching is one that cannot be extended (not necessarily maximum).
Flow Network Construction
Given a bipartite graph , construct a flow network :
- Add source and sink
- For each , add directed edge with capacity 1
- For each , add directed edge with capacity 1
- For each (with , ), direct from to with capacity 1
Why This Works
Run Ford-Fulkerson or Edmonds-Karp on . All capacities are 1 and integral, so the maximum flow assigns 0 or 1 to every edge. By the Integrality Theorem, there exists an integral maximum flow (all edge flows are integers). Since each vertex in receives at most 1 unit from , each sends flow to at most one . Symmetrically, each receives at most 1 unit. The edges with flow 1 form a valid matching.
The size of the maximum matching equals the value of the maximum flow: .
Running Time
Maximum flow value is at most , so at most augmentations. Each BFS finds an augmenting path in time. Total: .
Alternating Paths View
An alternating path (with respect to matching ) alternates between edges not in and edges in . An augmenting path is an alternating path starting and ending at unmatched vertices. Augmenting along such a path (toggling matched/unmatched status of each edge) increases matching size by 1.
The flow-based BFS on the residual network corresponds exactly to finding augmenting paths in the alternating-paths view:
- Forward edge (, not in matching) corresponds to residual forward capacity
- Backward edge (, in matching) corresponds to residual reverse capacity (flow cancellation)
Worked Example
Bipartite graph: , .
Edges: , , , , .
Flow network: (all capacity 1), , , (all capacity 1), (all capacity 1).
Run Edmonds-Karp:
- Path : match
- Path : match
- Path ? No, residual: is saturated, so exists (reverse). Path then reverse (not valid, has no outgoing residual to directly…).
Actually: (reverse, cancels existing match) . This is the augmenting path: unmatch , match and . Now matching: , , .
- Path : match .
Maximum matching: , , with size 3. This is a perfect matching (all vertices matched).
Beyond BFS: Hopcroft-Karp
Hopcroft-Karp finds multiple vertex-disjoint shortest augmenting paths per BFS round using a layered graph and DFS. Running time improves to . This is examinable but less commonly examined than the basic reduction.
Summary
| Concept | Detail |
|---|---|
| Reduction | bipartite flow network with , , unit capacities |
| Matching size | |
| FF/EK running time | |
| Hopcroft-Karp | |
| Integrality | Unit capacities + FF integral input integral output |
Past Tripos: y2024p1q9, y2023p2q7.