Created
June 20, 2019 07:16
-
-
Save christopheragnus/916a06ce2442d09fc54f5420635ec1c6 to your computer and use it in GitHub Desktop.
Gale-Shapley algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stableMatching { | |
Initialize all m ∈ M and w ∈ W to free | |
while ∃ free man m who still has a woman w to propose to { | |
w = first woman on m’s list to whom m has not yet proposed | |
if w is free | |
(m, w) become engaged | |
else some pair (m', w) already exists | |
if w prefers m to m' | |
m' becomes free | |
(m, w) become engaged | |
else | |
(m', w) remain engaged | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment