Bipartite Graphs and Matchings

⚡ Key Takeaways

A bipartite graph is a graph whose vertices split into two disjoint sets with edges only crossing between them. A matching is a set of edges sharing no endpoints. Key result: König's Theorem and Hall's Marriage Theorem completely characterize when perfect matchings exist and relate maximum matchings to minimum vertex covers. Applies to assignment problems, scheduling, and network flows. Foundations laid by Frobenius (1917), König, and Hall (1935).

💡 The Core Insight

Bipartite structure forbids odd cycles, which makes "augmenting paths" behave perfectly. A matching is maximum if and only if no augmenting path exists, and in bipartite graphs these paths can be found greedily. This turns matching into a problem of local search along alternating paths, and the obstruction to a perfect matching is always a single "deficient" set, never something subtle.

Formal Statement

DefinitionBipartite Graph

A graph G=(V,E)G=(V,E) is bipartite with bipartition (X,Y)(X,Y) if

1
V=X∪Y,X∩Y=∅,∀ e={u,v}∈E: (u∈X∧v∈Y).\quad V = X \cup Y,\quad X \cap Y = \varnothing,\quad \forall\, e=\{u,v\}\in E:\ (u\in X \wedge v\in Y).

Derivation hint: directly encode "every edge crosses the partition" as a logical constraint on endpoints. Here X,YX,Y are the two parts (or color classes). The numbers ∣X∣|X| and ∣Y∣|Y| are the sizes of the sides.

TheoremCharacterization by Odd Cycles (König 1916)

A graph is bipartite if and only if it contains no cycle of odd length.

2
G bipartite  ⟺  ∀ cycles C⊆G: ∣C∣≡0(mod2).\quad G \text{ bipartite} \iff \forall \text{ cycles } C \subseteq G:\ |C| \equiv 0 \pmod 2.

Derivation hint: 2-color the graph by BFS parity; a conflict appears exactly when an odd closed walk forces a vertex to need both colors.

DefinitionMatching, Maximum, Perfect

A matching M⊆EM\subseteq E satisfies: no two edges of MM share an endpoint.

3
∀ e,f∈M, e≠f: e∩f=∅.\quad \forall\, e,f\in M,\ e\neq f:\ e\cap f = \varnothing.

Derivation hint: "share no endpoint" is just disjointness of the two-element edge sets.

  • MM is maximum if no matching has more edges: ∣M∣=ν(G)|M|=\nu(G), where ν(G)\nu(G) is the matching number.
  • MM is perfect if every vertex is matched: 2∣M∣=∣V∣2|M| = |V|.
  • A vertex covered by MM is saturated; otherwise exposed/free.
DefinitionVertex Cover and Covering Number

A vertex cover is a set U⊆VU\subseteq V touching every edge:

4
∀ e={u,v}∈E: u∈U ∨ v∈U.\quad \forall\, e=\{u,v\}\in E:\ u\in U \ \vee\ v\in U.

Derivation hint: a cover must "hit" each edge, so at least one endpoint lies in UU. The minimum size of a vertex cover is τ(G)\tau(G).

TheoremHall's Marriage Theorem (1935)

Let GG be bipartite with parts (X,Y)(X,Y). There exists a matching saturating XX iff for every subset S⊆XS\subseteq X,

5
∣N(S)∣ ≥ ∣S∣,\quad |N(S)| \ \ge\ |S|,

where N(S)={y∈Y:∃ x∈S, {x,y}∈E}N(S)=\{y\in Y:\exists\, x\in S,\ \{x,y\}\in E\} is the neighborhood of SS. Derivation hint: necessity is counting; sufficiency follows by augmenting-path induction or by reducing to König's theorem.

TheoremKönig's Theorem (1931)

In any bipartite graph, the maximum matching number equals the minimum vertex cover number:

6
ν(G)=τ(G).\quad \nu(G) = \tau(G).

Derivation hint: build a vertex cover of size ν(G)\nu(G) from an alternating-path reachability argument; weak duality gives ν≤τ\nu\le\tau always.

DefinitionDeficiency Version (König–Ore)

The maximum matching size obeys the deficiency formula:

7
ν(G)=∣X∣−max⁡S⊆X(∣S∣−∣N(S)∣).\quad \nu(G) = |X| - \max_{S\subseteq X}\big(|S|-|N(S)|\big).

Derivation hint: the term max⁡(∣S∣−∣N(S)∣)\max(|S|-|N(S)|) measures the worst Hall-violating set; subtract this "deficiency" from ∣X∣|X|.

Why It Holds / Derivation

ProofHall's Theorem via Augmenting Paths

We prove the nontrivial direction: if ∣N(S)∣≥∣S∣|N(S)|\ge|S| for all S⊆XS\subseteq X, then XX can be saturated.

Step 1 — Setup. Let MM be a maximum matching. Suppose for contradiction some x0∈Xx_0\in X is exposed. We build a set SS violating Hall's condition.

Step 2 — Alternating tree. Grow an alternating path from x0x_0: edges alternate between non-matching (from XX to YY) and matching (from YY back to XX). Let

8
S={x∈X:x reachable from x0 via alternating path},T=Nreached(S)⊆Y.\quad S = \{x\in X : x \text{ reachable from } x_0 \text{ via alternating path}\},\quad T = N_{\text{reached}}(S)\subseteq Y.

Derivation hint: collect exactly the vertices the alternating search touches on each side.

Step 3 — Structure of reached vertices. Every y∈Ty\in T is matched (else we found an augmenting path from x0x_0 to yy, contradicting maximality of MM), and its match lies in SS. Hence MM gives a bijection between TT and S∖{x0}S\setminus\{x_0\}, so

9
∣T∣=∣S∣−1.\quad |T| = |S| - 1.

Derivation hint: every matched y∈Ty\in T pairs to a distinct reachable x∈Sx\in S, and x0x_0 alone is unmatched.

Step 4 — N(S)=TN(S)=T. Any neighbor yy of some x∈Sx\in S is reachable (extend the alternating path), so N(S)⊆TN(S)\subseteq T; trivially T⊆N(S)T\subseteq N(S). Thus ∣N(S)∣=∣T∣=∣S∣−1<∣S∣|N(S)|=|T|=|S|-1<|S|, violating Hall's condition — contradiction. Therefore no exposed vertex exists and XX is saturated. ■\blacksquare

∎
ProofKönig's Theorem from a Maximum Matching

Let MM be a maximum matching. Let U⊆XU\subseteq X be the exposed vertices of XX. Let ZZ be the set of all vertices reachable from UU by alternating paths. Define

10
C=(X∖Z) ∪ (Y∩Z).\quad C = (X\setminus Z)\ \cup\ (Y\cap Z).

Derivation hint: take unreachable XX-vertices plus reachable YY-vertices — exactly the "blocked" side of each matching edge.

Claim 1 — CC is a vertex cover. Any edge {x,y}\{x,y\} with x∈Z∩Xx\in Z\cap X: its other end yy must be in ZZ (reachability extends), so y∈Cy\in C. If x∉Zx\notin Z, then x∈Cx\in C. So every edge is covered.

Claim 2 — ∣C∣=∣M∣|C|=|M|. No edge of MM connects X∖ZX\setminus Z to Y∩ZY\cap Z (that would extend reachability), and every vertex of CC is matched (exposed XX-vertices are in ZZ, hence excluded; exposed YY-vertices are unreachable). Each matching edge contributes exactly one vertex to CC. Hence ∣C∣=∣M∣=ν(G)|C|=|M|=\nu(G). Since τ≥ν\tau\ge\nu always (each matching edge needs its own cover vertex) and we exhibited a cover of size ν\nu, we get τ=ν\tau=\nu. ■\blacksquare

∎
mathematician · Philip Hall | 1904–1982

Philip Hall, a British group theorist at Cambridge, proved the Marriage Theorem in 1935 while studying systems of distinct representatives. Though best known for deep contributions to finite group theory (Hall subgroups, the Hall–Higman theorem), his combinatorial result became a cornerstone of matching theory. The evocative "marriage" framing — matching people to acceptable partners — popularized the abstract statement, and the theorem's many equivalent forms (König, Menger, max-flow) reveal it as one face of a single duality principle.

Building Intuition

🧠 Intuition

Picture jobs (XX) and workers (YY), with an edge meaning "this worker can do this job." A perfect assignment is a perfect matching. Hall's condition says: assignment fails only if some group of kk jobs collectively can be done by fewer than kk workers — a genuine bottleneck. König's duality is the accountant's version: the fewest "checkpoints" (vertices) needed to monitor every connection equals the most independent connections you can run simultaneously. The augmenting path is the trick that fixes a suboptimal assignment: find a free job, follow a chain that re-shuffles existing assignments, and end at a free worker — flipping the chain increases the match by one.

Figure
An alternating/augmenting path in a bipartite graph. Bold gold edges are in matching M; the dashed path augments it.

```svg

X Y x1 x2 x3 y1 y2 y3 gold = matched, dashed = unmatched path edges x1 free → y2 → x2 → y3 → x3 free

```

Worked Examples

ExampleChecking Hall's Condition Numerically

Given: Jobs X={a,b,c}X=\{a,b,c\}, workers Y={1,2,3}Y=\{1,2,3\}, with capability edges: aa–{1,2}, bb–{1}, cc–{1}.

Step 1 — Test small sets. ∣N({a})∣=2≥1|N(\{a\})|=2\ge1. ∣N({b})∣=1≥1|N(\{b\})|=1\ge1. Good.

Step 2 — Test the suspicious set. Take S={b,c}S=\{b,c\}: N(S)={1}N(S)=\{1\}, so ∣N(S)∣=1|N(S)|=1 but ∣S∣=2|S|=2.

Step 3 — Hall's condition fails. Since 1<21<2, no matching saturates XX.

Step 4 — Maximum matching size. Deficiency =max⁡(∣S∣−∣N(S)∣)=∣{b,c}∣−∣{1}∣=1=\max(|S|-|N(S)|)=|\{b,c\}|-|\{1\}|=1. By [7]:

ν=∣X∣−def=3−1=2.\nu = |X|-\text{def} = 3-1 = 2.

Answer: ν=2 (no perfect matching; one job unfillable)\boxed{\nu=2 \text{ (no perfect matching; one job unfillable)}}

ExampleVerifying König Duality

Given: Bipartite graph X={x1,x2}X=\{x_1,x_2\}, Y={y1,y2}Y=\{y_1,y_2\} with edges x1y1,x1y2,x2y1x_1y_1, x_1y_2, x_2y_1 (a "path-plus" shape).

Step 1 — Find a maximum matching. Take M={x1y2, x2y1}M=\{x_1y_2,\ x_2y_1\}. Both XX-vertices saturated; ∣M∣=2|M|=2.

Step 2 — Is it maximum? Only 4 vertices; a matching of size 2 is perfect, so ν=2\nu=2.

Step 3 — Find a minimum vertex cover. C={x1,y1}C=\{x_1,y_1\}: edge x1y1x_1y_1 hit by x1x_1, x1y2x_1y_2 by x1x_1, x2y1x_2y_1 by y1y_1. Size 22. No single vertex covers all 3 edges, so τ=2\tau=2.

Step 4 — Confirm [6]. ν=τ=2\nu = \tau = 2. ✓

Answer: ν=τ=2, perfect matching exists\boxed{\nu=\tau=2,\ \text{perfect matching exists}}

Common Misconceptions

⚠️ Common mistake

Hall's condition is on XX, not symmetric. A matching saturating XX may exist while YY has exposed vertices (when ∣Y∣>∣X∣|Y|>|X|). For a perfect matching you also need ∣X∣=∣Y∣|X|=|Y|, and then checking Hall on XX suffices. Also: König's theorem (ν=τ\nu=\tau) holds only for bipartite graphs. In general graphs ν≤τ≤2ν\nu\le\tau\le 2\nu, and the gap can be real.

Counterexample

König fails in general graphs. Take the triangle K3K_3 (odd cycle, not bipartite). Maximum matching has ν=1\nu=1 (one edge; the third vertex is left out). But minimum vertex cover needs τ=2\tau=2 vertices, since one vertex leaves an uncovered edge. Here ν=1≠2=τ\nu=1\ne 2=\tau, so duality breaks precisely because K3K_3 has an odd cycle.

Connections

connection

Bipartite matching is the combinatorial heart of Max-Flow Min-Cut Theorem: model the matching as a flow network with unit capacities, and an integral max flow equals the maximum matching, while a min cut yields a minimum vertex cover — giving König's theorem as a corollary. It is one instance of Menger's Theorem (vertex-disjoint paths) and of LP duality, since the bipartite matching polytope is integral (the constraint matrix is totally unimodular). The weighted version connects to The Assignment Problem and the Hungarian algorithm, and the structural theory generalizes via Tutte's Theorem for matchings in arbitrary graphs.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1912: Frobenius initiates the algebraic study of bipartite structures, examining when a 0–1 matrix has a nonzero permanent (equivalent to a perfect matching).
- 1916: Dénes König characterizes bipartiteness by the absence of odd cycles, founding graph-theoretic matching.
- 1917: Frobenius proves the determinant/permanent condition for perfect matchings in bipartite graphs.
- 1931: König proves the min–max theorem ν=τ\nu=\tau for bipartite graphs (also derived independently by Egerváry in weighted form the same year).
- 1935: Philip Hall publishes the Marriage Theorem on systems of distinct representatives.
- 1947: Tutte generalizes to arbitrary graphs with the Tutte–Berge formula's precursor.
- 1955: Harold Kuhn introduces the Hungarian algorithm for weighted assignment, crediting König and Egerváry.
- 1965: Jack Edmonds gives a polynomial algorithm for general (non-bipartite) matching via blossoms.
- 1973: Hopcroft and Karp give an O(V E)O(\sqrt{V}\,E) algorithm for maximum bipartite matching, still a benchmark.
- 1990: Karp, Vazirani & Vazirani analyze online bipartite matching (the RANKING algorithm, competitive ratio 1−1/e1-1/e).

Subtleties & Limits

open-problem

While exact bipartite matching is solved efficiently, several frontiers remain active. Online bipartite matching with stochastic arrivals: closing the gap between known competitive ratios (e.g., beating 1−1/e1-1/e under various arrival models) is ongoing. Dynamic matching: maintaining a near-maximum matching under edge insertions/deletions with low update time is a major area, with conditional lower bounds. Counting perfect matchings (the permanent) is #P\#P-hard even for bipartite graphs (Valiant 1979), though approximate counting is possible via the Jerrum–Sinclair–Vigoda MCMC algorithm. Finally, the precise communication and streaming complexity of approximating maximum matching remains incompletely understood.

See Also

Max-Flow Min-Cut Theorem · Menger's Theorem · Tutte's Theorem · The Assignment Problem · Stable Matching and Gale–Shapley · Linear Programming Duality · Edge Coloring · Total Unimodularity