BITS Pilani
CS F364: Design and Analysis of Algorithms

Bipartite Matching via Max-Flow

Lecture 24 |2026-07-09

Today’s Agenda: Matching via Max-Flow

  1. The Edmonds-Karp Improvement
  2. Maximum Bipartite Matching Reduction
  3. The Integrality Theorem

1. Recap: The Problem with Ford-Fulkerson

Ford-Fulkerson runtime: O(E \cdot |f^*|).

  • If capacities are large (e.g. |f^*| = 2^{30}), this is exponential in the input size.
  • Solution: choose augmenting paths smartly.

2. The Edmonds-Karp Algorithm

Key Idea

Always pick the shortest augmenting path (fewest edges) using BFS.

Result

  • Shortest-path distances in G_f increase monotonically.
  • At most O(VE) augmentations.
  • Each BFS takes O(E).
  • Total: O(VE^2) — independent of capacities!

3. Maximum Bipartite Matching

Problem: Given a bipartite graph G = (L \cup R, E), find a matching of maximum size.

Reduction to Max-Flow:

  1. Add supersource s, connect to all u \in L with capacity 1.
  2. Add supersink t, connect all v \in R to t with capacity 1.
  3. Direct all original edges L \to R with capacity 1.
  4. Find max flow. Max flow value = max matching size!

4. Why the Reduction Works

Each unit of flow = one matched pair

  • Flow s \to u \to v \to t means u is matched to v.
  • Unit capacity on s \to u ensures u is matched to at most one partner.
  • Unit capacity on v \to t ensures v is matched to at most one partner.

The Integrality Theorem

If all capacities are integers, the max flow found by Ford-Fulkerson is integral (flow on every edge is an integer). * Since all capacities are 1, every edge has flow either 0 or 1. * The edges with flow 1 form a valid matching. ✓

5. Complexity of Matching via EK

  • Max flow value \le |L| \le V.
  • At most V BFS augmentations.
  • Each BFS: O(E).
  • Total: O(VE) — much better than general O(VE^2)!

Concept Check: Bipartite Matching

Question

“What happens if we set all L \to R edge capacities to \infty instead of 1?”

Answer: The reduction still works! The unit capacities on s \to L and R \to t already enforce that each vertex is matched at most once. The internal edges don’t need the restriction.