algorithms in stable matchings
galeshaply_all.py <n> <seed>
This program can be used for :
- Generating random preference list for n men n women
- Generating all possible stable matchings for this preference list
- Analyzing rotations and drawing H(M) for a given stable matching
- Plotting the whole lattice of stable matchings
Sample Run:
[user@system StableMatching]$ python galeshaply_all.py 10
Enter your choice:
1) Random SM instance
2) Random SM instance with disjoint M0 and Mz
3) Random SM instance where preference lists are latin squares
: 1
seed: 47827303
Mens List:
0 -> [9, 5, 0, 7, 6, 8, 1, 4, 3, 2]
1 -> [4, 2, 9, 1, 6, 3, 0, 8, 7, 5]
2 -> [6, 5, 9, 8, 0, 2, 7, 1, 4, 3]
3 -> [7, 9, 1, 2, 0, 3, 8, 5, 6, 4]
4 -> [1, 8, 4, 7, 3, 2, 9, 5, 6, 0]
5 -> [7, 2, 6, 3, 0, 8, 9, 5, 4, 1]
6 -> [7, 9, 2, 8, 0, 4, 1, 5, 3, 6]
7 -> [3, 7, 5, 6, 9, 4, 2, 1, 0, 8]
8 -> [6, 3, 2, 4, 1, 8, 7, 5, 0, 9]
9 -> [5, 4, 7, 2, 9, 3, 0, 8, 1, 6]
Womens List:
0 -> [0, 6, 7, 3, 9, 1, 5, 2, 4, 8]
1 -> [0, 2, 1, 9, 8, 4, 7, 6, 3, 5]
2 -> [0, 5, 1, 8, 3, 2, 6, 4, 9, 7]
3 -> [4, 0, 2, 6, 5, 9, 8, 7, 3, 1]
4 -> [3, 8, 4, 2, 9, 6, 7, 5, 1, 0]
5 -> [0, 2, 8, 4, 6, 9, 1, 7, 5, 3]
6 -> [1, 4, 7, 9, 5, 6, 8, 0, 3, 2]
7 -> [5, 2, 0, 3, 7, 6, 9, 1, 8, 4]
8 -> [5, 4, 8, 7, 0, 6, 3, 1, 2, 9]
9 -> [8, 2, 0, 7, 4, 6, 1, 5, 3, 9]
Total number of matchings: 9
M0 -> (9, 2, 5, 0, 1, 7, 8, 3, 6, 4)
M1 -> (5, 2, 9, 0, 1, 7, 8, 3, 6, 4)
M2 -> (9, 2, 5, 0,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