Data Structures and Algorithms

Stable Matchings

executive summary

Given equal-sized sets X and Y,
where every element in X has a ranking over elements of Y and vice versa,
our goal is to find an optimal bijection between X and Y

We cover the main ideas of the Gale-Shapley algorithm in these slides.

link to companion notes

The story, all names, characters, and incidents portrayed in this class are fictitious.

No identification with actual persons is intended or should be inferred.

Blocking Pairs

When A is matched to B

and X is matched to Y

but A prefers Y over B

and Y prefers A over X.

Goal: Stable Marriage

An assignment with

no blocking pairs.

Let's look at an algorithm
for computing a stable matching.

Men = [n] & Women = [n]

ManPref[m, j] is the identity of the j-th
ranked woman in m’s preference list 

WomanPref[w, j] is the identity of the jth
ranked man in w’s preference list.

Next[w] →  the rank of the
best unproposed man for w.

Current[m] →   is the identity of
the woman m is currently engaged to
and is −1 if m is free

FreeWomenList is the set of unmatched women.

Rank is an n ×n 2D array such that
Rank[m,w] is the rank of w in m’s preference list.

Does the algorithm terminate?

Does the algorithm produce a valid matching?

Does the algorithm produce a stable matching?

How long does the algorithm need to run?

Yes, because every woman proposes at most \(n\) times.

Yes, because the algorithm does not stop as long as at least one woman is single, and no woman is matched to more than one man.

If (m,w) in the final output are a blocking pair, then w proposed to m before proposing to his matched partner.

What was m doing when w proposed to her?

Ifshe accepted, why did he break the alliance?

There are at most \(n^2\) proposals.

Stable Matchings

By Neeldhara Misra