Folioby Interconnected
Log InSign Up

Matchings and Coverings

Augmenting paths, Berge's theorem, Hall's marriage theorem, König's theorem, stable matchings via the Gale--Shapley algorithm, and weighted matchings --- all with complete proofs.

FO
Folio Official
March 1, 2026

1. Basic Concepts

Definition 1 (Matching).
A matching in a graph G=(V,E) is a set M⊆E of pairwise non-adjacent edges (no two edges in M share an endpoint). A vertex incident to an edge of M is said to be matched (or saturated). A matching of maximum cardinality is called a maximum matching. A matching that saturates every vertex of G is a perfect matching.

In the following bipartite graph, the thick edges form a matching M={{x1​,y2​},{x2​,y3​}} of size 2. The vertex x3​ is unmatched:

x1​
y1​
y2​
x2​
y3​
x3​

Definition 2 (Augmenting path).
An alternating path with respect to a matching M is a path whose edges alternate between M and E∖M. An alternating path whose two endpoints are both unsaturated by M is called an augmenting path.

In the graph above, the path x3​−y1​−x1​−y2​−x2​−y3​ is not augmenting because y3​ is matched. However, the path x3​−y1​ is an augmenting path (both x3​ and y1​ are unmatched). Flipping along it yields the larger matching {{x3​,y1​},{x1​,y2​},{x2​,y3​}}:

x1​
y2​
y1​
x2​
y3​
x3​

2. Berge's Theorem

Theorem 3 (Berge's theorem).
A matching M is a maximum matching if and only if there is no augmenting path with respect to M.
Proof.
(⇒): If an augmenting path P exists, the symmetric difference M′=M⊕E(P) (exchanging matched and unmatched edges along P) is a matching with ∣M′∣=∣M∣+1, contradicting the maximality of M.

(⇐): Suppose M is not maximum, and let M∗ be a maximum matching with ∣M∗∣>∣M∣. Consider H=M⊕M∗. Every vertex of H has degree at most 2 (at most one edge from M and one from M∗), so each connected component of H is a path or an even-length cycle. Since ∣M∗∣>∣M∣, some component has more edges from M∗ than from M. A cycle has equally many edges from each, so this component must be a path. It begins and ends with edges of M∗, meaning both endpoints are unsaturated by M. This path is therefore an augmenting path for M. □

3. Matchings in Bipartite Graphs

Definition 4 (Bipartite graph).
A graph G=(V,E) is bipartite if V can be partitioned as V=X⊔Y so that every edge joins a vertex in X to a vertex in Y.

The following bipartite graph satisfies Hall's condition (∣N(S)∣≥∣S∣ for every S⊆X) and therefore admits a perfect matching of X:

x1​
y1​
y2​
x2​
y3​
x3​

Theorem 5 (Hall's marriage theorem).
A bipartite graph G=(X⊔Y,E) has a matching that saturates every vertex of X if and only if ∣N(S)∣≥∣S∣ for every S⊆X, where N(S) denotes the neighborhood of S.
Proof.
(⇒): If a matching M saturates X, then for any S⊆X, the matching pairs the vertices of S with ∣S∣ distinct vertices in Y, so ∣N(S)∣≥∣S∣.

(⇐): We prove the contrapositive. Suppose no matching saturates X. Let M be a maximum matching with ∣M∣<∣X∣. Pick an unsaturated vertex u∈X. Let Z be the set of all vertices reachable from u via alternating paths. Set S=Z∩X and T=Z∩Y. Since u∈S and u is unsaturated, u contributes to S. Since there is no augmenting path (Berge's theorem), every vertex in T is matched by M, and its partner under M lies in S (being reachable via the alternating path). Thus ∣T∣=∣S∣−1. Moreover, N(S)⊆T: if some neighbor y of S lay outside T, then y would be reachable from u via an alternating path, placing y in Z∩Y=T, a contradiction. Therefore ∣N(S)∣≤∣T∣=∣S∣−1<∣S∣. □

4. König's Theorem

Definition 6 (Vertex cover).
A vertex cover of G=(V,E) is a set C⊆V such that every edge has at least one endpoint in C.
Theorem 7 (König's theorem).
In a bipartite graph, the size of a maximum matching equals the size of a minimum vertex cover.
Proof.
For any matching M and vertex cover C, we have ∣C∣≥∣M∣ (each edge of M requires at least one vertex of C to cover it). We show equality is attained. Take a maximum matching M and construct the reachability set Z as in the proof of Hall's theorem. Define C=(X∖Z)∪(Y∩Z). One verifies that ∣C∣=∣M∣ and that C is a vertex cover. □

5. Stable Matchings

Definition 8 (Stable matching).
Let M be a set of n men and W a set of n women, each with a strict preference ordering over the opposite set. A perfect matching μ is unstable if there exist a man m and a woman w, not paired with each other, such that m prefers w to μ(m) and w prefers m to μ(w). A matching with no such pair is called a stable matching.
Theorem 9 (Gale–Shapley).
The Gale–Shapley algorithm (men-proposing version) terminates in finitely many steps and outputs a stable matching. Moreover, the matching it produces is men-optimal: every man is matched with the best partner he could have in any stable matching.
Proof.
Termination. Each man proposes to each woman at most once, so the algorithm terminates after at most n2 proposals.

Stability. Suppose an unstable pair (m,w) exists. Either m never proposed to w, or he did and was rejected. In the first case, m prefers μ(m) to w (since men propose in order of preference), contradicting the assumption that (m,w) is unstable. In the second case, w was holding a proposal she preferred to m at the time; since a woman's partner can only improve over the course of the algorithm, w prefers μ(w) to m in the final matching — again a contradiction.

Men-optimality is established by inductively showing that no man is ever rejected by a woman who could be his partner in some stable matching. □

6. Weighted Matchings

Remark 10.
When each edge e carries a weight w(e), a matching M maximizing ∑e∈M​w(e) is called a maximum-weight matching. For bipartite graphs, the Hungarian method (Kuhn–Munkres algorithm) finds a maximum-weight matching in O(n3) time. This method is based on LP duality and can be seen as a weighted generalization of KöO(n3) running time.
Graph TheoryDiscrete MathematicsTextbookMatchingsHall's TheoremKönig's Theorem
FO
Folio Official

Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.

1 followers·107 articles
Graph Theory TextbookPart 8 of 13
Previous
Directed Graphs and Topological Sorting
Next
Network Flows

Share your expertise with the world

Write articles with LaTeX support, build your audience, and earn from your knowledge.

Start Writing — It's Free

More from Folio Official

Folio Official·March 1, 2026

Paths and Connectivity

We formalize the notions of walks, paths, and cycles, then develop the theory of connected components, vertex and edge connectivity, cut vertices and bridges, the characterization of bipartite graphs, and Menger's theorem.

Graph TheoryDiscrete MathematicsTextbook
3
Folio Official·March 1, 2026

Eulerian and Hamiltonian Graphs: Two Classical Traversal Problems

From the Bridges of Königsberg to Euler's theorem on Eulerian circuits, directed Eulerian graphs, Hamiltonian cycles, the theorems of Ore and Dirac, and the NP-completeness of the Hamiltonian cycle problem.

Graph TheoryDiscrete MathematicsTextbook
1
Folio Official·March 1, 2026

Network Flows

Flow networks, the max-flow min-cut theorem, the Ford--Fulkerson method, the Edmonds--Karp algorithm, Dinic's algorithm, and the reduction of bipartite matching to maximum flow.

Graph TheoryDiscrete MathematicsTextbook
Folio Official·March 1, 2026

Recurrence Relations and Counting: Solving Linear Recurrences

We present the method of characteristic equations for solving linear recurrences with constant coefficients, treat the case of repeated roots, discuss nonhomogeneous recurrences, establish the equivalence with generating functions, and introduce matrix exponentiation and the Kitamasa method.

CombinatoricsDiscrete MathematicsTextbook