David Gale Created 2026-10-18 Updated 2026-11-05
David Gale was a mathematician whose research connected optimization, game theory and mathematical economics. With Lloyd Shapley, he proved the existence of a stable matching under the classical two-sided preference model and gave an algorithm to construct one.[ref] Stability means that no unmatched pair would both prefer each other to their assigned partners. This is different from maximizing a single total score: the requirement rules out a mutually beneficial deviation. The Gale-Shapley algorithm became a foundation for applications such as assigning students to schools and doctors to residency programs.
Figure 1.
Portrait of David Gale
. George M. Bergman, photograph; Filetime, existing portrait crop. CC BY-SA 4.0, via Wikimedia Commons. Source.
Gale-Shapley algorithm Created 2026-10-14 Updated 2026-10-18
The Gale-Shapley algorithm constructs a stable matching by letting one side propose and the other hold its best offer so far. The word "deferred" is essential: a held proposal is tentative and can be replaced. David Gale and Lloyd Shapley presented this construction in their 1962 paper, College Admissions and the Stability of Marriage, §3, printed pp. 12–13; §4 extends it to college quotas and unacceptable pairs.
For the one-partner bipartite graph model, designate as proposers and as receivers:
  • Start with the empty matching in a graph. Each proposer keeps a pointer to its first untried acceptable partner.
  • Choose an unmatched vertex in a matching whose list is not exhausted. It proposes to its highest-ranked untried neighbour of a vertex and advances its pointer permanently.
  • If holds nobody, it holds . Otherwise compares with its currently held proposer, keeps the one it prefers, and rejects the other. A displaced proposer becomes unmatched and may propose again later.
  • Stop when every unmatched proposer has exhausted its list. The held pairs are the output matching in a graph.
Held proposers wait; only unmatched proposers act. A receiver can replace its held partner, whereas a proposer never tries the same edge twice. Isolated vertices simply remain unmatched. These rules also describe incomplete acceptable lists and unequal sides without adding fictitious acceptable partners.
For the preference lists under stable matching, choose available proposers in queue data structure order, initially , adding rejected proposers at the end. The proposals are , , , , . At the fourth proposal, replaces its held by because . This frees to try , producing .
Figure 1.
Five proposals in the Gale-Shapley algorithm: Y replaces a tentative partner before the final stable matching
. Details.
Reverse the proposing side. Starting in the order , the proposals are , , , . Now rejects because it already holds . The result is . Thus the choice of proposing side can change the output even with strict preferences and complete lists.
Why does the procedure work? Each edge receives at most one proposal, so at most proposals occur. At all times, the held edges form a matching in a graph, and each receiver holds its favourite proposer among all proposals received. A receiver's held partner can only improve according to its strict preference. If a proposer prefers to its final partner, or ends unmatched while is acceptable, it must already have proposed to . A rejection means then held someone better, and its final partner is at least as good. Such an edge cannot be a blocking pair in stable matching. This covers every possible blocking pair in stable matching, proving stability at termination.
With a queue data structure of unmatched proposers, a next-choice pointer for each list, and constant-time receiver-rank lookups, each proposal takes constant work. Using Big O notation, the time complexity is including initialization, provided list construction and rank preprocessing also take . Edge-indexed ranks with cross-referenced list entries, or expected constant-time hash lookups, allow sparse storage proportional to . Repeatedly scanning a receiver's preference list to compare offers would lose this bound. For complete lists with vertices per side, and the bound is . Initializing full rank tables itself costs time and space, even when only a sparse set of pairs is acceptable.
The Gale-Shapley algorithm does more than establish existence: with strict preferences, its output is a proposer-optimal stable matching.[ref] It is also a receiver-pessimal stable matching, as proved below. Both qualifications compare partners across stable matchings.
Each vertex of a bipartite graph has a strict preference ordering of its neighbours; every neighbour is preferred to being unmatched. A stable matching in a bipartite graph is a matching in a graph with no blocking edge: an unused edge blocks if both endpoints prefer each other to their assigned partners, interpreting an unmatched endpoint as willing to accept any neighbour. Stability does not require a perfect matching in a graph.
For existence, run the Gale-Shapley algorithm. Whenever a vertex in the first part is unmatched and has an untried neighbour, it proposes to its most preferred untried neighbour. A receiver keeps its preferred proposal and rejects the other, including any previously held proposal. At most proposals occur, so the procedure stops with a matching in a graph. Suppose an edge blocked this final matching in a graph. Since prefers to its final partner, or is unmatched, must have proposed to . But a receiver's held proposal only improves, so 's final partner is preferred to if was rejected. If was not rejected, the edge is in the matching in a graph. Both alternatives contradict blocking. Every finite bipartite preference instance therefore has a stable matching.
For the mutual-worst edge in stable matchings, let be stable matchings with and . We give the argument using alternating graph components including possible unmatched endpoints. If were unmatched in , then would have to prefer its -partner to , since otherwise would block . Following the -edge from , stability of forces its other endpoint to have and prefer an -partner. Stability of then forces the next vertex to have and prefer an -partner. These implications continue along the alternating graph component of . They cannot stop, because at a missing next edge the preceding edge would block the appropriate matching in a graph. They also cannot close into a cycle in a graph, since the graph component already has endpoint . This contradiction proves that is matched in . The same reasoning applies to .
Now prefers its -partner to , because is its worst choice. Along the alternating graph component, stability of forces that partner to prefer its -partner; stability of forces the next vertex in 's part to prefer its -partner, and so on. A graph path graph component is impossible by the same endpoint argument, so this is a cycle in a graph. Thus throughout this cycle in a graph the part containing prefers and the part containing prefers . In particular must prefer to its -partner. That contradicts being 's worst choice. Hence an edge ranked last by both endpoints, if present in one stable matching, is present in every stable matching.
For the list edge coloring assertion, let be the maximum degree. We first prove that the chromatic index is . Use induction on the number of edges, with a proper -edge coloring of . Some color is missing at and some color is missing at . If , color with it. Otherwise the edges of colors form alternating graph paths and even cycles in a graph. The graph component containing cannot contain : an alternating graph path from , starting with color , would end at with color , have even length, and place in the same bipartition class. Swap in the graph component containing . Now is missing at both ends of , so it can be colored . The lower bound is immediate at a vertex of vertex degree .
Fix such a proper coloring . Orient the line graph toward the smaller color at vertices in the first part of , and toward the larger color at vertices in the second part. A vertex of the line graph corresponding to an edge of color has outdegree at most
Every induced subgraph of this orientation has a digraph kernel. Indeed, restrict to its edge set in the original bipartite graph, give first-part vertices a preference for smaller colors and second-part vertices a preference for larger colors, and choose a stable matching. Its edges form an independent set in the line graph. Every edge outside the matching in a graph has an endpoint whose partner is preferred to it, by stability; thus it has an outgoing edge to the independent set. This proves that the orientation is a kernel-perfect directed graph.
Here is the kernel list-coloring lemma with its proof. If a kernel-perfect directed graph has lists satisfying , choose any color appearing in a list and a digraph kernel of the induced subgraph on vertices whose lists contain . Color with , delete , and delete from the remaining lists. Each remaining vertex that loses a color had an outgoing neighbour in , so its outdegree decreases by at least one; the list inequality persists. Vertices not losing a color also retain the inequality. Induction on the number of vertices completes a proper list coloring.
Lists of size satisfy that lemma for our oriented line graph, so . Identical lists show . Consequently the Galvin theorem for bipartite list edge coloring gives
The empty graph is immediate; if parallel edges are allowed, orient their line-graph adjacency in both directions when the two endpoints prescribe opposite directions. The outdegree bound still holds, and the same stable matching and digraph kernel proof applies with preferences on incident edges.
For fixed strict preferences, a proposer-optimal stable matching gives each proposer its best partner obtainable in any stable matching, with unmatched ranked last. The Gale-Shapley algorithm achieves all these individual optima simultaneously. In the worked example, gives partners ranked , respectively; the alternative gives them ranks .
Suppose a first rejection of a pair belonging to some stable matching occurs when rejects for . Every partner prefers to has already rejected it, so none can be its partner in . If , then prefers to , while prefers to : a blocking pair in stable matching, a contradiction. Hence no rejected pair is stable, and each proposer receives its best stable partner. Under strict preferences this also makes the outcome independent of proposal order.
For fixed strict preferences, the same output of the Gale-Shapley algorithm gives each receiver its worst partner obtainable in any stable matching, treating unmatched as last. "Worst" is restricted to stable possibilities: a receiver might still receive its favourite acceptable partner if every stable matching assigns it that partner. Reversing the proposing side gives receivers their best stable partners instead.
For a short proof, let be a proposer-optimal stable matching and any other stable matching. If a receiver preferred to , then proposer optimality would make prefer to , since the partners differ and preferences are strict. The pair would block . Therefore no receiver prefers its partner in to its partner in . In the worked example, right-side ranks in are for , whereas gives them . Neither outcome is universally best for both sides.
Stable matching in a bipartite graph Created 2026-10-14 Updated 2026-10-18
A stable matching in a bipartite graph pairs two groups so that no acceptable unpaired pair would both rather be together. Give a finite bipartite graph a strict preference ordering at each vertex over its neighbours of a vertex. An edge means that both endpoints regard the pair as acceptable; every acceptable partner ranks above being unmatched. Lists may be incomplete, and and may have unequal cardinalities. A matching in a graph is stable when it has no blocking pair in stable matching.
Write for the partner of a vertex , or if is an unmatched vertex in a matching. An unused edge is a blocking pair in stable matching precisely when
where denotes the strict preference at and ranks below every neighbour of a vertex. Both inequalities matter: wanting a different partner alone cannot upset a stable matching. A stable matching need not be a perfect matching; the Gale-Shapley algorithm still finds one with incomplete lists and unequal sides.
Here is an original example on the complete bipartite graph , with and . Read each row from best to worst:
There are two stable matchings,
For , the only unpaired partners preferred by left vertices are wanting and wanting . But prefers its partner to , and prefers its partner to . Hence neither is a blocking pair in stable matching. For , the left vertices want with , with or , and with or . In every case the right vertex prefers its current partner: has , has , and has .
By contrast, is a perfect matching with a blocking pair in stable matching : prefers to , while prefers to . The abandoned partners need not agree to the change; stability tests the incentives of the two endpoints of the unused edge.
There are permutations of right partners. The following table lists every blocking pair in stable matching for each perfect matching; the middle column gives the partners of in that order:
This exhausts the stable matchings: any nonperfect matching in a graph here leaves an unmatched vertex on each side, and those two form a blocking pair in stable matching because every cross-pair is acceptable. Notice that every left vertex prefers and every right vertex prefers . Stability can accommodate opposing interests without selecting a single universally preferred outcome.
A stable matching addresses the possibility of mutually beneficial departures. Its definition contains no numerical total social benefit or maximum-weight matching objective. For example, assigning benefit to each edge of and zero to every other edge makes the unique maximum-weight matching, yet still blocks it under the displayed preference relations. Such external benefits need not represent participants' rankings.