Network Flows, Cuts & Matching

bipartite matching via flow

Suppose you have applicants on the left, jobs on the right, and a line drawn whenever an applicant is qualified for a job. You want to hire as many people as possible, each person to at most one job and each job to at most one person. This is maximum bipartite matching, and a small trick turns it into a flow problem you already know how to solve.

Build a flow network: add a source s with an edge of capacity 1 to every left vertex, an edge of capacity 1 from every right vertex to a sink t, and for each original qualification edge a left-to-right edge of capacity 1. Now run any max-flow algorithm. Because all capacities are 1, the integrality theorem guarantees an integer maximum flow, and in such a flow each left vertex sends at most 1 unit and each right vertex receives at most 1 unit — exactly the matching constraints. The edges carrying 1 unit between left and right form a maximum matching, and the value of the max flow equals the size of the maximum matching. A residual augmenting path corresponds precisely to an alternating path that grows the matching, so flow's machinery and classical matching theory are the same thing in disguise.

This reduction is the canonical example of modeling a combinatorial problem as flow, and it is genuinely useful: Edmonds-Karp or Dinic solve it directly, with Dinic running in O(E * sqrt(V)) on these unit-capacity networks (the Hopcroft-Karp bound). It also imports flow's duality for free — the max-flow min-cut theorem on this network becomes Konig's theorem (max matching equals min vertex cover in bipartite graphs). The one caution: this clean reduction is for bipartite graphs. General (non-bipartite) matching is also polynomial but needs Edmonds' blossom algorithm, not plain flow, because odd cycles break the simple construction.

Three applicants {A, B, C}, three jobs {1, 2, 3}, with A-1, A-2, B-1, C-3 qualified. The flow network sends 1 unit s->A->2->t, 1 unit s->B->1->t, 1 unit s->C->3->t, value 3 — a perfect matching. If instead only A and B could do only job 1, max flow would be 1: the bottleneck cut exposes that two applicants compete for a single job.

Unit capacities turn 'at most one each' into capacity constraints; the integer max flow is a maximum matching of equal size.

This works because the graph is bipartite (no odd cycles). For general graphs you need Edmonds' blossom algorithm — plain max-flow on an undirected non-bipartite graph does not correctly model matching.

Also called
maximum bipartite matchingmatching as flow最大二分匹配