Skip to content
CoreSource checked

Gale-Shapley Algorithm

Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching.

Quick Facts

Compact metadata for implementation and discovery.

Category
Graph Traversal
Difficulty
Intermediate
Family
Stable Matching
Tier
Core
Status
Verified
Review
Source Checked
Sources
2
Formulas
0
Relationships
5
Code example
Ready
Visualization
Ready

Overview

Gale-Shapley Algorithm applies letting one side propose while the other side keeps its best current proposal to handle stable matching with a named, inspectable procedure.

Core Concepts

stable matchingmatchingdynamic programminggraph traversal

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(E)

Average

O(V^2 E)

Worst

O(V^2 E)

Space

O(V + E)

When to Use

  • Use Gale-Shapley Algorithm when solving stable matching and you want to benefit from Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching.
  • Choose it when O(V^2 E) average/worst-case time and O(V + E) memory match your workload profile.
  • Prefer it over Edmonds' Blossom Algorithm or Bipartite Matching DFS when the problem structure favors stable matching.

When Not to Use

  • Avoid when the graph model does not match the method's direction, weight, or connectivity assumptions.
  • Avoid when a simpler traversal gives the same information with less bookkeeping.

What It Does

  • Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching
  • Organizes the work around stable matching and matching.

Use Cases

  • Production and research workloads requiring stable matching via Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching.
  • Stable Matching pipelines where O(V^2 E) time and O(V + E) space fit system constraints.
  • Engineering comparisons against Edmonds' Blossom Algorithm and Bipartite Matching DFS when tuning stable matching.

Inputs

  • Two equal-sized sets of agents with strict ranked preference lists

Outputs

  • Stable bijection pairing with no blocking pair

Pseudocode

  1. 1.Construct the graph representation G = (V, E) and initialize auxiliary structures for stable matching (matching).
  2. 2.Seed the initial frontier, partition, or residual capacities according to Gale-Shapley Algorithm's invariants.
  3. 3.Iteratively process vertices or edges by Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching.
  4. 4.Maintain structural invariants (stable matching, matching, dynamic programming) and prune or contract resolved subproblems.
  5. 5.Extract and return the final stable matching structure from the converged graph state.

Canonical Example

Input
Two equal-sized sets of agents with strict ranked preference lists configured for a representative stable matching test case
Output
Stable bijection pairing with no blocking pair satisfying Gale-Shapley Algorithm invariants
Explanation
Gale-Shapley Algorithm processes the input by Gale-Shapley Algorithm uses letting one side propose while the other side keeps its best current proposal for stable matching, tracking stable matching and matching to produce the verified stable matching result.

Implementation Notes

  • Represent vertices and edges explicitly before optimizing storage.
  • Keep graph direction, weights, and multiedges clear in tests.
  • Record tie-breaking when multiple valid outputs exist.

Common Pitfalls

  • Using the method on the wrong graph type, such as directed versus undirected or weighted versus unweighted.
  • Forgetting disconnected components or isolated vertices.
  • Letting tie-breaking hide nondeterministic output in tests.

Interactive Mechanism Walkthrough

Graph Frontier & Edge Relaxation

Show letting one side propose while the other side keeps its best current proposal on a small stable matching example.

Gale-Shapley Algorithm mechanism walkthrough step 1 of 5suvwxt
Step 1 of 5: Construct the graph representation G = (V, E) and initialize auxiliary structures for stable matching (matching).
graph-traversal-mechanism

Notes

Gale-Shapley Algorithm operates in O(V^2 E) time and O(V + E) space within the Stable Matching family. Often compared with Edmonds' Blossom Algorithm and Bipartite Matching DFS.

Sources (2)

What each reference supports for this entry.

The Stable Marriage Problem: Structure and Algorithms

Book

Reference for Gale-Shapley Algorithm's stable matching model and deferred-acceptance proposal process.

Gale-Shapley Stable Marriage

Paper

Original stable matching reference for proposal-based deferred acceptance.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Gale-Shapley Algorithm uses Edmonds' Blossom Algorithm as a subroutine, representation, or supporting idea while letting one side propose while the other side keeps its best current proposal.

Gale-Shapley Algorithm uses Bipartite Matching DFS as a subroutine, representation, or supporting idea while letting one side propose while the other side keeps its best current proposal.

Gale-Shapley Algorithm uses Hungarian Algorithm as a subroutine, representation, or supporting idea while letting one side propose while the other side keeps its best current proposal.

Tags

GraphTraversalMatching