Bipartite Graphs and Matchings

Study Sheet

Bipartite Graphs and Matchings

Two-sided graphs, matchings, Hall's marriage theorem, and stable matchings

Bipartite Graphs and Odd Cycles

Concept
Bipartite graphs and the odd-cycle theorem

A graph G=(V,E)G = (V, E) is bipartite if VV splits into two parts XX and YY with every edge joining XX to YY — no edge lies inside XX or inside YY. Theorem: GG is bipartite if and only if it has no cycle of odd length.

The two parts are exactly a proper 22-coloring: color every vertex of XX white and every vertex of YY black, and no edge ever joins two same-colored vertices. A cycle has to alternate colors as it goes around, so after an even number of steps it returns to its starting color — but after an odd number of steps it would need the start and end vertex (the very same vertex) to hold opposite colors at once, which is impossible. That gives the easy half of the theorem outright. The hard half — that having no odd cycle ANYWHERE in the graph is also enough to guarantee a full 22-coloring — is proved in Why It Works by growing the coloring outward from one vertex at a time, exactly as a breadth-first search would.

Example
Coloring the 33-cube by parity
000001010011100101110111
The 33-cube Q3Q_3: shaded vertices have even weight, unshaded odd.

Let Q3Q_3 have one vertex for each of the 88 binary strings of length 33, with an edge between two strings whenever they differ in exactly one bit — 000-001000\text{-}001, 000-010000\text{-}010, and so on. Color each vertex by the parity of its number of 11s: X={000,011,101,110}X = \{000, 011, 101, 110\} (even) and Y={001,010,100,111}Y = \{001, 010, 100, 111\} (odd). Flipping one bit always changes the number of 11s by exactly 11, so it always changes parity — every one of the 1212 edges joins XX to YY, and Q3Q_3 is bipartite.

Example
The wheel W5W_5 has a triangle
12345h
The wheel W5W_5: the triangle h,1,2h,1,2 (bold) is an odd cycle.

Let W5W_5 have a hub hh joined to every vertex of a 55-cycle 1-2-3-4-5-11\text{-}2\text{-}3\text{-}4\text{-}5\text{-}1 — 55 rim edges plus 55 spokes, 1010 edges on 66 vertices. The hub and any two consecutive rim vertices form a triangle, for instance h,1,2h,1,2: the edges h1h1, 1212, 2h2h are all present, a 33-cycle. An odd cycle, so by the theorem W5W_5 is not bipartite — no 22-coloring can work, however the colors are assigned.

Example
A genuine problem: does one extra edge break bipartiteness?
123abc
One edge abab (dashed) inside a part of K3,3K_{3,3} creates the triangle a,b,1a,b,1.

Start from the complete bipartite graph K3,3K_{3,3} on X={a,b,c}X=\{a,b,c\}, Y={1,2,3}Y=\{1,2,3\} (all 99 cross edges), bipartite by construction. Add a single edge abab inside XX. Is the result still bipartite? Now a,b,1a,b,1 form a triangle: abab is the new edge, and a1a1, b1b1 are both original cross edges — a 33-cycle has appeared. By the theorem the graph is no longer bipartite: one edge inside a part is already enough to destroy it, no matter how many legitimate cross edges surround it.

Side note
Where it goes wrong

Triangle-free is not the same as bipartite. The 55-cycle 1-2-3-4-5-11\text{-}2\text{-}3\text{-}4\text{-}5\text{-}1 has no triangle at all — no three mutually adjacent vertices — yet it is still not bipartite, since it is itself an odd cycle of length 55. The theorem rules out EVERY odd length, not just length 33; checking only for triangles catches none of the longer odd cycles.

Try it
Try it: splitting incompatible chemicals

Five chemicals are arranged so each is incompatible only with its two neighbors in a cycle: 1-2,2-3,3-4,4-5,5-11\text{-}2, 2\text{-}3, 3\text{-}4, 4\text{-}5, 5\text{-}1. Can they be sorted into two storage rooms so no two incompatible chemicals share a room?

Show the answer

This asks whether the incompatibility graph — the 55-cycle C5C_5 — is bipartite. It is an odd cycle (length 55), so by the theorem it has no proper 22-coloring: however the five are split into two rooms, one room holds at least 33 of the 55, and among any 33 chemicals from a 55-cycle two are consecutive, hence incompatible. **No** — two rooms are not enough; splitting them {1,3}\{1,3\}, {2,4}\{2,4\}, {5}\{5\} into three rooms does work.

Matchings

Concept
Matchings, maximal and maximum

A matching M⊆EM \subseteq E is a set of edges no two of which share a vertex. MM saturates a vertex if some edge of MM touches it. MM is maximal if no edge can be added to it without breaking the no-shared-vertex rule; MM is maximum if no matching of the graph is larger; a perfect matching saturates every vertex. The matching number ν(G)\nu(G) is the size of a maximum matching, and it can never exceed min⁡(∣X∣,∣Y∣)\min(|X|, |Y|) in a bipartite graph, since each MM-edge uses one vertex from each side.

Maximal only means "stuck for now" — no single edge happens to extend it — while maximum means "as large as any matching could possibly be." Every maximum matching is maximal (if it could be extended it would not be largest), but the next example shows the reverse fails badly: a careless, greedy choice of edges can get stuck far short of maximum. Recognizing when a matching truly cannot be beaten is the deeper question, answered by Berge's theorem in Why It Works: a matching is maximum exactly when it admits no augmenting path, an alternating path of unmatched/matched/unmatched/… edges that starts and ends at unsaturated vertices. Hall's theorem and Konig's theorem, next, both grow out of this same alternating-path idea.

Example
Augmenting a stuck matching
1234
The flipped matching {12,34}\{12,34\} (bold) saturates all four vertices.

On the path 1-2-3-41\text{-}2\text{-}3\text{-}4 (edges 12,23,3412, 23, 34), the single edge {23}\{23\} is a matching: it is maximal, since both 1212 and 3434 touch an already-saturated vertex (22 or 33) and cannot be added. Yet it leaves 11 and 44 unsaturated, and 1-2-3-41\text{-}2\text{-}3\text{-}4 is itself an alternating path from one unsaturated vertex to the other — unmatched 1212, matched 2323, unmatched 3434. Flipping every edge on it (drop 2323, add 1212 and 3434) gives M={12,34}M = \{12, 34\}, a matching of size 22 that saturates all 44 vertices: a perfect matching, and since ν(P4)≤min⁡(2,2)=2\nu(P_4) \le \min(2,2) = 2 for its natural bipartition {1,3},{2,4}\{1,3\},\{2,4\}, it is maximum.

Example
A genuine problem: verifying a perfect matching
123abc
The bold matching {1a,2b,3c}\{1a, 2b, 3c\} is perfect: every vertex saturated once.

Three students {1,2,3}\{1,2,3\} each like exactly two of three project slots {a,b,c}\{a,b,c\}, forming the 66-cycle of preferences 1-a,1-b,2-b,2-c,3-a,3-c1\text{-}a, 1\text{-}b, 2\text{-}b, 2\text{-}c, 3\text{-}a, 3\text{-}c. Can every student get a slot they like, each slot going to one student? Try M={1a,2b,3c}M = \{1a, 2b, 3c\}: all three edges are in the preference list, and 1,2,3,a,b,c1, 2, 3, a, b, c are six different vertices, each appearing exactly once across MM — a perfect matching. Every student is satisfied.

Example
A matching can never beat the smaller side
123c
Every edge shares the hub cc, so only one can ever be matched.

A hub cc is compatible with three candidates 1,2,31, 2, 3 (edges c1,c2,c3c1, c2, c3) and the candidates are compatible with nothing else. Any matching can use at most one of these edges, since all three share the vertex cc: ν=1\nu = 1, even though there are 33 candidates — matched to the single vertex cc, at most 11 of them ever gets saturated at a time, no matter which edge is chosen.

Side note
Where it goes wrong

Believing a matching is maximum just because no edge can be added to it right now. The matching {23}\{23\} on the path 1-2-3-41\text{-}2\text{-}3\text{-}4 is exactly this trap: it is maximal (stuck), yet {12,34}\{12, 34\} is twice as large. "Stuck" only rules out adding ONE edge at a time; an augmenting path can grow a matching by removing one edge and adding two, which a purely greedy check never considers.

Try it
Try it: does a partial matching need checking?

A bipartite graph has ∣X∣=5|X| = 5 and ∣Y∣=3|Y| = 3. A matching saturates all of YY. Must it be maximum, even though it leaves 22 vertices of XX unsaturated?

Show the answer

Every matching uses one vertex from each side per edge, so its size can never exceed min⁡(∣X∣,∣Y∣)=min⁡(5,3)=3\min(|X|, |Y|) = \min(5,3) = 3. A matching that saturates all of YY already has size 33, the largest any matching could possibly reach — **yes, it must be maximum**, even though it is far from perfect on the XX side.

Hall's Marriage Theorem

Concept
Hall's condition

For a bipartite graph with parts X,YX, Y, write N(S)N(S) for the set of all neighbors (in YY) of a subset S⊆XS \subseteq X. Hall's Marriage Theorem: a matching saturating every vertex of XX exists if and only if ∣N(S)∣≥∣S∣|N(S)| \ge |S| for EVERY subset S⊆XS \subseteq X — Hall's condition.

Necessity is immediate: the vertices of SS must be matched to ∣S∣|S| distinct vertices, all of which are neighbors of SS by definition, so N(S)N(S) had better contain at least that many. The theorem's force is that this one family of simple counting checks, one inequality per subset, is also SUFFICIENT — no other obstruction can ever block an XX-saturating matching. The name comes from the classical story: XX is a set of people, YY a set of acceptable marriage partners, and an edge means "willing to marry." Why It Works proves sufficiency by induction, peeling off one matched pair at a time.

Example
Checking Hall's condition directly
1234ABC
Hall's condition holds; the bold matching saturates A,B,CA, B, C.

Applicants {A,B,C}\{A, B, C\} apply to jobs {1,2,3,4}\{1,2,3,4\} with AA qualified for {1,2}\{1,2\}, BB for {2,3}\{2,3\}, CC for {3,4}\{3,4\}. Every subset of X={A,B,C}X = \{A,B,C\} must be checked: the three singletons each have ∣N(S)∣=2≥1|N(S)|=2 \ge 1; the three pairs have N({A,B})={1,2,3}N(\{A,B\}) = \{1,2,3\}, N({B,C})={2,3,4}N(\{B,C\}) = \{2,3,4\}, N({A,C})={1,2,3,4}N(\{A,C\}) = \{1,2,3,4\}, all of size ≥2\ge 2; and N({A,B,C})={1,2,3,4}N(\{A,B,C\}) = \{1,2,3,4\}, size 4≥34 \ge 3. Hall's condition holds throughout, so an XX-saturating matching exists — for instance A-1,B-2,C-3A\text{-}1, B\text{-}2, C\text{-}3.

Example
A genuine problem: a subset that breaks Hall's condition
123ABC
Shaded: the bottleneck S={A,B}S=\{A,B\} and N(S)={1}N(S)=\{1\}, with ∣N(S)∣<∣S∣|N(S)|<|S|.

Applicants {A,B,C}\{A,B,C\} apply to jobs {1,2,3}\{1,2,3\}, but AA and BB are BOTH qualified only for job 11, while CC is qualified for all of 1,2,31, 2, 3. The full set N({A,B,C})={1,2,3}N(\{A,B,C\}) = \{1,2,3\} has size 3≥33 \ge 3, which looks fine — but the pair S={A,B}S = \{A,B\} has N(S)={1}N(S) = \{1\}, size 1<2=∣S∣1 < 2 = |S|: Hall's condition fails on this smaller subset. No matter how jobs are assigned, AA and BB both need job 11 and only one can have it, so no XX-saturating matching exists; the best possible matching has size 22 (for instance A-1,C-2A\text{-}1, C\text{-}2), leaving one of A,BA, B unmatched.

Example
A corollary: regular bipartite graphs always pair off

Take K4,4K_{4,4} on X={1,2,3,4}X=\{1,2,3,4\}, Y={a,b,c,d}Y=\{a,b,c,d\} and delete the perfect matching 1a,2b,3c,4d1a, 2b, 3c, 4d, leaving every vertex with degree exactly 33 — a 33-regular bipartite graph. For any S⊆XS \subseteq X, counting edges leaving SS gives exactly 3∣S∣3|S|, and every one of those edges lands in N(S)N(S), where each vertex can absorb at most 33 of them (its own degree); so 3∣S∣≤3∣N(S)∣3|S| \le 3|N(S)|, i.e. ∣N(S)∣≥∣S∣|N(S)| \ge |S| — Hall's condition holds automatically, for any kk-regular bipartite graph, not just this one. A perfect matching must exist, and indeed 1b,2a,3d,4c1b, 2a, 3d, 4c is one: four edges of the 1212 remaining ones, touching all 88 vertices exactly once.

Side note
Where it goes wrong

Checking Hall's condition only on S=XS = X itself, rather than on every subset. In the job example above, N({A,B,C})={1,2,3}N(\{A,B,C\}) = \{1,2,3\} has size 3≥33 \ge 3 — the full-set check passes — yet the SMALLER subset {A,B}\{A,B\} is where the condition actually fails. Hall's theorem demands the inequality for every one of the 2∣X∣2^{|X|} subsets; the full set alone proves nothing.

Try it
Try it: a hiring bottleneck

People {P,Q,R,S}\{P,Q,R,S\} are qualified for slots as follows: PP and QQ for {1}\{1\} only, RR for {1,2}\{1,2\}, SS for {3,4}\{3,4\}. Does an XX-saturating matching exist?

Show the answer

Check the subset {P,Q,R}\{P,Q,R\}: its neighborhood is N({P,Q,R})={1}∪{1}∪{1,2}={1,2}N(\{P,Q,R\}) = \{1\} \cup \{1\} \cup \{1,2\} = \{1,2\}, of size 22, while ∣{P,Q,R}∣=3|\{P,Q,R\}| = 3. Since 2<32 < 3, Hall's condition fails on this subset. **No** — three people (P,Q,RP, Q, R) compete for only two slots (1,21, 2) between them, so no matching can saturate all of {P,Q,R,S}\{P,Q,R,S\}, regardless of SS's independent access to 3,43, 4.

Konig's Theorem and Vertex Covers

Concept
Vertex covers and Konig's theorem

A vertex cover is a set C⊆VC \subseteq V touching every edge (each edge has at least one endpoint in CC). Its minimum size is τ(G)\tau(G). For ANY graph, ν(G)≤τ(G)\nu(G) \le \tau(G): the ν\nu edges of a maximum matching are pairwise disjoint, so covering all of them needs at least one cover vertex per edge, and no two matching edges can share that vertex. Konig's theorem: for a BIPARTITE graph, equality always holds, ν(G)=τ(G)\nu(G) = \tau(G).

The inequality ν≤τ\nu \le \tau costs nothing and holds everywhere, matching or no matching, bipartite or not; it is Konig's theorem that is special, promising a cover no larger than the matching that lower-bounds it. The classical construction (Why It Works) starts from a maximum matching MM, marks every vertex reachable from an unsaturated XX-vertex by an alternating path, and builds the cover from the unmarked part of XX together with the marked part of YY — turning Hall's theorem's subset SS into an explicit, provably minimum set of vertices. This equality is also the bipartite case of the much more general max-flow min-cut theorem, previewed in Directed Graphs and Flows.

Example
Matching and cover, side by side
123ABC
Bold: the matching {A1,C2}\{A1, C2\}. Shaded: the cover {1,C}\{1, C\} — every bold edge touches a shaded vertex.

Recall the bottleneck graph from Hall's Marriage Theorem: A,B,CA, B, C applying to jobs 1,2,31,2,3, with A-1,B-1,C-1,C-2,C-3A\text{-}1, B\text{-}1, C\text{-}1, C\text{-}2, C\text{-}3. Its maximum matching has size ν=2\nu = 2, for instance {A-1,C-2}\{A\text{-}1, C\text{-}2\}. A cover of size 22 is {1,C}\{1, C\}: edge A1A1 and B1B1 both touch 11, while C1,C2,C3C1, C2, C3 all touch CC — every edge is covered. Since ν≤τ\nu \le \tau always and this cover achieves τ≤2\tau \le 2, Konig's theorem is confirmed: ν=τ=2\nu = \tau = 2, by a cover that mixes one vertex from each side.

Example
A tiny cover for a lopsided graph
123c
Shaded {c}\{c\} is already a minimum cover; bold shows a maximum matching inside it.

A hub cc connects to leaves 1,2,31, 2, 3 and nothing else connects them (recall A matching can never beat the smaller side, Matchings). The single vertex {c}\{c\} touches all three edges c1,c2,c3c1, c2, c3, so τ≤1\tau \le 1; and τ≥ν=1\tau \ge \nu = 1 always, so τ=1\tau = 1 exactly. The minimum cover need not involve the three leaves at all — one well-chosen vertex can cover arbitrarily many edges if they all meet there.

Example
A genuine problem: matchings, covers, and independent sets together

In the A,B,C/1,2,3A,B,C/1,2,3 graph above (n=6n = 6 vertices, τ=2\tau = 2), find a maximum independent set — a set of vertices with no edge between any two of them. By Gallai's identity, a maximum independent set has size n−τ=6−2=4n - \tau = 6 - 2 = 4 in any graph. Try {A,B,2,3}\{A, B, 2, 3\}: AA and BB are not adjacent (both only touch 11), 22 and 33 are not adjacent (both lie in YY, and YY has no internal edges), and none of A,BA, B is adjacent to 22 or 33 (their only neighbor is 11). All (42)=6\binom{4}{2}=6 pairs are checked and none is an edge: {A,B,2,3}\{A,B,2,3\} is independent, of size 44, matching the formula exactly.

Side note
Where it goes wrong

Assuming ν=τ\nu = \tau outside bipartite graphs. The triangle K3K_3 has ν=1\nu = 1 (any two of its three edges share a vertex, so only one can be matched) but τ=2\tau = 2 (one vertex always misses the opposite edge; two vertices, say 11 and 22, are needed to touch all three edges 12,13,2312, 13, 23). Konig's theorem needs the bipartite hypothesis; dropping it can make τ\tau strictly larger than ν\nu.

Try it
Try it: matching and cover on a path
123abcd
Bold: the matching {a1,b2,c3}\{a1,b2,c3\}. Shaded: the cover {1,2,3}\{1,2,3\}.

Find ν\nu and τ\tau for the path a-1-b-2-c-3-da\text{-}1\text{-}b\text{-}2\text{-}c\text{-}3\text{-}d (seven vertices, six edges), and exhibit both a maximum matching and a minimum cover.

Show the answer

A maximum matching takes every other edge: {a1,b2,c3}\{a1, b2, c3\}, size 33, leaving only dd unsaturated (no larger matching fits in 66 edges on a path). A cover of size 33 is {1,2,3}\{1, 2, 3\}: edge a1a1 and 1b1b touch 11, b2b2 and 2c2c touch 22, c3c3 and 3d3d touch 33 — all six edges covered. Since ν≤τ\nu \le \tau always and this cover attains 33, Konig's theorem gives ν=τ=3\nu = \tau = \mathbf{3}.

Stable Matchings

Concept
Stability and the Gale-Shapley algorithm

Given two equal-size sets, say men and women, each person ranks every member of the other set. A perfect matching has a blocking pair if some unmatched man mm and woman ww BOTH prefer each other to their current partners. A matching with no blocking pair is stable. Gale-Shapley theorem: a stable matching always exists, and the deferred-acceptance algorithm (men propose in order of their own preference; a woman holds her best offer so far and rejects the rest) always finds one.

This is a different kind of question from Hall's and Konig's theorems: those assumed a fixed yes/no compatibility graph and asked whether a perfect matching exists at all; here the underlying graph is already complete (everyone ranks everyone), so a perfect matching trivially exists, and the question is which ONE to pick given everyone's preferences. A blocking pair is a standing threat to break the matching apart, since both people involved would rather be with each other, so stability is the only kind of matching that can actually survive once people are free to renegotiate. Why It Works proves the algorithm always terminates and never leaves a blocking pair behind.

Example
Running Gale-Shapley by hand
ABCXYZ
The men-proposing stable matching A-X,B-Y,C-ZA\text{-}X, B\text{-}Y, C\text{-}Z.

Men A,B,CA,B,C rank women X,Y,ZX,Y,Z as A:X,Y,ZA: X,Y,Z;   B:Y,X,Z\;B: Y,X,Z;   C:X,Y,Z\;C: X,Y,Z. Women rank men as X:B,A,CX: B,A,C;   Y:A,B,C\;Y: A,B,C;   Z:A,B,C\;Z: A,B,C. Round 11: A→XA\to X, B→YB\to Y, C→XC\to X; XX holds AA over CC (her list ranks AA above CC), rejecting CC. Round 22: C→YC\to Y (his next choice); YY already holds BB, and her list ranks BB above CC, so YY rejects CC again. Round 33: C→ZC\to Z, his last choice, accepted. The result is A-X,B-Y,C-ZA\text{-}X, B\text{-}Y, C\text{-}Z. Checking every one of the 99 possible pairs confirms no blocking pair: each person who is not with their top choice (only CC, matched to his last choice ZZ) is paired with someone who in turn prefers their own current partner, so neither side wants to break away.

Example
A genuine problem: finding a blocking pair
ABXY
The matching A-Y,B-XA\text{-}Y, B\text{-}X (plain); the blocking pair A-XA\text{-}X (bold, dashed).

Men A,BA,B and women X,YX,Y all rank XX above YY (for the men) and AA above BB (for the women): A,B:X,YA, B: X, Y;   X,Y:A,B\;X, Y: A, B. Is the matching A-Y,B-XA\text{-}Y, B\text{-}X stable? Check the pair A,XA, X, who are not matched to each other: AA prefers XX to his current partner YY (since AA ranks XX first), and XX prefers AA to her current partner BB (since XX ranks AA first). Both prefer each other to their current partners, so (A,X)(A,X) is a blocking pair: this matching is unstable, and it would unravel as soon as AA and XX compared notes. The stable matching here is the "obvious" one, A-X,B-YA\text{-}X, B\text{-}Y, where every blocking attempt fails because each person already has their first choice.

Example
Women proposing: a different stable matching
ABCXYZ
The women-proposing stable matching A-Y,B-X,C-ZA\text{-}Y, B\text{-}X, C\text{-}Z.

Run the SAME preferences as the first example, but let the women propose. Round 11: X→BX\to B, Y→AY\to A, Z→AZ\to A; AA holds YY over ZZ (his list ranks YY above ZZ), rejecting ZZ. Round 22: Z→BZ\to B (her next choice); BB already holds XX, and his list ranks XX above ZZ, so BB rejects ZZ again. Round 33: Z→CZ\to C, accepted. The result is A-Y,B-X,C-ZA\text{-}Y, B\text{-}X, C\text{-}Z — DIFFERENT from the men-proposing matching A-X,B-Y,C-ZA\text{-}X, B\text{-}Y, C\text{-}Z found before, yet checking all 99 pairs again shows it too has no blocking pair. The same preferences admit (at least) two different stable matchings, and each man does WORSE here than under his own side's proposals (AA gets YY instead of XX; BB gets XX instead of YY) — the content of the proposer-optimality theorem in Why It Works.

Side note
Where it goes wrong

Thinking a matching is unstable just because ONE person is unhappy. In the first example, CC is matched to his last choice ZZ and would clearly rather have XX or YY — but that alone changes nothing, since instability needs a MUTUAL preference. CC prefers XX to ZZ, yet XX (matched to AA, her top choice) does not prefer CC back; CC prefers YY to ZZ, yet YY (matched to BB, her second choice but still above CC) does not prefer CC either. One-sided wishful thinking never breaks stability; both members of a pair must prefer each other.

Try it
Try it: is this matching already stable?

Men A,BA,B rank A:Y,XA: Y,X and B:X,YB: X,Y; women rank X:A,BX: A,B and Y:B,AY: B,A. Is the matching A-X,B-YA\text{-}X, B\text{-}Y stable?

Show the answer

Check the only other possible pair, AA and YY (and symmetrically B,XB, X): YY's own ranking is B,AB, A, so YY already prefers her CURRENT partner BB over AA — she has no interest in switching, so (A,Y)(A, Y) cannot be a blocking pair no matter what AA prefers. The same reasoning kills (B,X)(B,X), since XX ranks her current partner AA above BB. Every woman already holds her own top choice, which alone guarantees no blocking pair can form. **Yes** — the matching is stable.

Why It Works

Necessity was shown in Hall's Marriage Theorem: if MM saturates XX, the vertices of SS are matched to ∣S∣|S| distinct vertices of N(S)N(S). For sufficiency, induct on n=∣X∣n = |X|. If n=1n=1, Hall's condition on the single vertex xx gives ∣N({x})∣≥1|N(\{x\})| \ge 1, so xx has some neighbor to match to. Assume the theorem for all smaller vertex sets, and suppose Hall's condition holds for XX with ∣X∣=n>1|X|=n>1. Case 1: every nonempty proper subset S⊊XS \subsetneq X satisfies the STRICT inequality ∣N(S)∣≥∣S∣+1|N(S)| \ge |S|+1. Pick any x∈Xx \in X and any neighbor yy of xx (one exists since ∣N({x})∣≥1|N(\{x\})|\ge1), and match xx to yy. In the graph G′G' with xx and yy deleted, any S⊆X∖{x}S \subseteq X\setminus\{x\} has NG′(S)⊇NG(S)∖{y}N_{G'}(S) \supseteq N_G(S)\setminus\{y\}, so ∣NG′(S)∣≥∣NG(S)∣−1≥∣S∣|N_{G'}(S)| \ge |N_G(S)|-1 \ge |S|, using the strict inequality from Case 1 (as SS is a proper subset of XX). So G′G' satisfies Hall's condition on X∖{x}X\setminus\{x\} (n−1n-1 vertices); by induction it has an (X∖{x})(X\setminus\{x\})-saturating matching, and adding xyxy saturates all of XX. Case 2: some nonempty proper subset SS has ∣N(S)∣=∣S∣|N(S)| = |S| exactly (equality, the tightest possible). Let T=N(S)T = N(S). Any subset of SS has the same neighbors in GG as in the induced bipartite graph on (S,T)(S,T) (its neighbors already lie in TT by definition of TT), so Hall's condition holds there too; since ∣S∣<n|S| < n, induction gives a matching M1M_1 that perfectly matches SS to TT. Now let G′′G'' be GG with SS and TT deleted, on parts X∖SX\setminus S and Y∖TY \setminus T. For any S′⊆X∖SS' \subseteq X\setminus S: NG(S′∪S)=NG′′(S′)∪TN_G(S' \cup S) = N_{G''}(S') \cup T (every neighbor of S′S' outside TT is a neighbor in G′′G'', and every neighbor of SS is already in TT), and these two pieces are disjoint, so ∣NG′′(S′)∣=∣NG(S′∪S)∣−∣T∣≥∣S′∪S∣−∣T∣=∣S′∣+∣S∣−∣T∣=∣S′∣|N_{G''}(S')| = |N_G(S'\cup S)| - |T| \ge |S'\cup S| - |T| = |S'| + |S| - |T| = |S'| (using Hall's condition in GG on S′∪SS'\cup S, and ∣S∣=∣T∣|S|=|T|). So G′′G'' satisfies Hall's condition on X∖SX \setminus S, which is smaller than XX since S≠∅S \ne \emptyset; by induction it has an (X∖S)(X\setminus S)-saturating matching M2M_2. Since M1M_1 and M2M_2 use disjoint vertex sets, M1∪M2M_1 \cup M_2 saturates all of X=S∪(X∖S)X = S \cup (X \setminus S). Either case produces an XX-saturating matching, completing the induction.

The inequality ν(G)≤τ(G)\nu(G) \le \tau(G) holds for every graph (Konig's Theorem and Vertex Covers): a maximum matching's edges are disjoint, so a cover needs a distinct vertex for each. For the reverse inequality in a bipartite graph, fix a maximum matching MM. Let U⊆XU \subseteq X be the vertices MM leaves unsaturated, and let ZZ be every vertex reachable from UU by an MM-alternating path — starting with a non-matching edge, then alternating matching/non-matching. Write ZX=Z∩XZ_X = Z \cap X, ZY=Z∩YZ_Y = Z \cap Y. Lemma: every y∈ZYy \in Z_Y is MM-saturated. If some reachable yy were unsaturated, the alternating path reaching it (starting at an unsaturated u∈Uu \in U, ending at the unsaturated yy, alternating the whole way) would be an augmenting path: flipping every edge on it — dropping its matching edges, adding its non-matching edges — produces a matching one edge larger than MM (each endpoint along the path keeps exactly one incident edge in the new matching, and the two endpoints u,yu,y gain an edge instead of having none), contradicting that MM is maximum. So every y∈ZYy \in Z_Y has a partner M(y)∈XM(y) \in X, and that partner is itself reachable (the path to yy extends by its matching edge to M(y)M(y)), so M(y)∈ZXM(y) \in Z_X. Let C=(X∖ZX)∪ZYC = (X \setminus Z_X) \cup Z_Y. CC is a vertex cover: take any edge xyxy with x∈ZXx \in Z_X and y∉ZYy \notin Z_Y (the only way xyxy could avoid CC), and derive a contradiction. If xy∈Mxy \in M: since U⊆ZXU \subseteq Z_X consists of unsaturated vertices, x∉Ux \notin U (it has the matching edge xyxy), so xx was reached via its OWN matching edge from some already-reachable y′∈ZYy' \in Z_Y with M(x)=y′M(x)=y'; but M(x)M(x) is unique, so y′=yy' = y, putting y∈ZYy \in Z_Y — contradiction. If xy∉Mxy \notin M: the alternating path reaching xx (either the trivial path if x∈Ux \in U, or one ending with a matching edge into xx) extends by the non-matching edge xyxy without breaking the alternation, reaching yy — so y∈ZYy \in Z_Y, again a contradiction. So no such edge exists, and CC covers every edge. ∣C∣=∣M∣|C| = |M|, so τ≤ν\tau \le \nu: every x∈X∖ZXx \in X \setminus Z_X is saturated (unsaturated vertices all lie in U⊆ZXU \subseteq Z_X), and its partner M(x)M(x) cannot lie in ZYZ_Y (if it did, the matching edge would make xx reachable too, contradicting x∉ZXx \notin Z_X) — so these ∣X∖ZX∣|X\setminus Z_X| vertices match, via MM, into DISTINCT vertices of Y∖ZYY \setminus Z_Y. Separately, by the Lemma every y∈ZYy \in Z_Y matches via MM into ZXZ_X. These two families of matching edges are disjoint (one ends in X∖ZXX\setminus Z_X, the other in ZXZ_X), giving ∣X∖ZX∣+∣ZY∣=∣C∣|X\setminus Z_X| + |Z_Y| = |C| distinct edges of MM, so ∣C∣≤∣M∣|C| \le |M|. Combined with ν≤τ\nu \le \tau, this forces τ(G)≤∣C∣≤ν(G)≤τ(G)\tau(G) \le |C| \le \nu(G) \le \tau(G), so all are equal: ν(G)=τ(G)\nu(G) = \tau(G).

Termination and perfection: each round, some man proposes to a woman he has never proposed to before, and each of the nn men has only nn women on his list, so the algorithm halts within n2n^2 rounds. Once engaged, a woman is NEVER free again — she only ever replaces her partner with someone she prefers more, never drops to nobody. Suppose the algorithm ended with some man mm unmatched; since he was never (re-)accepted, he must have proposed to and been rejected by every one of the nn women. Each such rejection happened because that woman was already engaged to someone else at the time, and since engaged women stay engaged, all nn women are engaged at the end. But a set of nn engaged women, each holding exactly one man, accounts for nn distinct engaged men — leaving no room for an n+1n+1-th man, let alone an unmatched mm among only nn men total. Contradiction; every man ends matched, and since women only end matched to a proposer, the result is a perfect matching. Stability: suppose the final matching has a blocking pair (m,w)(m,w): mm prefers ww to his partner wmw_m, and ww prefers mm to her partner mwm_w. Since mm proposes in strictly decreasing order of preference and ended up with wmw_m, worse than ww, he must have proposed to ww at some earlier round and been turned away — either rejected immediately, or accepted then later displaced. At that moment ww was holding (or came to hold) some man she preferred to mm. From then on ww's held partner only improves (by the no-free-fall rule above), so her FINAL partner mwm_w is preferred by ww at least as much as whoever beat mm that round, which was itself preferred to mm — so ww prefers mwm_w to mm. This contradicts the blocking pair's assumption that ww prefers mm to mwm_w. So no blocking pair can survive: the matching is stable.

Say a man is better off in a stable matching M∗M^* than in the algorithm's result GG if he prefers M∗(m)M^*(m) to G(m)G(m). Suppose, for contradiction, some man is better off in some stable M∗M^*; then at some point during the algorithm he must have proposed to M∗(m)M^*(m) and been rejected (he proposes in decreasing order and ends up with something worse than M∗(m)M^*(m), so M∗(m)M^*(m) was reached and turned down along the way). Among every such rejection, across every man and every stable M∗M^*, take the FIRST one to occur in time: woman w=M∗(m)w = M^*(m) rejects mm (immediately, or by later displacing him) in favor of some m′m' she currently prefers over mm. Because this is the FIRST time any woman has rejected her own M∗M^*-partner, the man m′m' has not yet (as of this moment) been rejected by M∗(m′)M^*(m') — so every woman m′m' has proposed to so far, including ww, ranks at least as high on m′m''s list as M∗(m′)M^*(m') does (he proposes in decreasing order, and has not yet been turned away by M∗(m′)M^*(m'), so he has not yet reached anyone ranked below her). In particular m′m' prefers ww to M∗(m′)M^*(m'), or is indifferent, so prefers ww at least as much. Now compare this to M∗M^*: ww prefers m′m' to m=M∗(w)m = M^*(w) (that is why she just rejected mm), and m′m' prefers ww to M∗(m′)M^*(m'). That is exactly a blocking pair for M∗M^* — contradicting that M∗M^* is stable. So no such first rejection can exist, and no man is ever better off in any stable matching than in the men-proposing algorithm's result: it is men-optimal.