Skip to content

Conradwangt/Stable-Matching

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A simple python implementation of the Gale Shapley sorting algorithm.
Auto generates some males, females and their partner preferences. Then pairs them up according to the algorithm.

USAGE
python StableMatching.py [-v]

I recommend using -v for verbose output.

    #Gale Shapley Stable Matching algorithm
    Initially all m E M and w E W are free
    While there is a man m who is free and hasn't proposed to every woman
      Choose such a man m
      Let W be the highest-ranked woman in m's preference list to whom m has not yet proposed
      If W is free then
        (m, w) become engaged
      Else w is currently engaged to m'
        If w prefers m' to m then
          m remains free
        Else w prefers m to mt
          (m, w) become engaged
        mt becomes free
        Endif
      Endif
    Endwhile
    Return the set S of engaged pairs

About

Gale Shapley stable matching algorithm implemented in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%