16 vector<vector<int>> matrix(n, vector<int>(n));
17 for(
int i = 0; i < n; ++i) {
18 for(
int rank = 0; rank < n; ++rank) {
19 int partner_id = prefs[i][rank];
20 matrix[i][partner_id] = rank;
26 TEST(StableMatchingTest, Simple2x2) {
37 vector<vector<int>> s_prefs = {{0, 1}, {0, 1}};
38 vector<vector<int>> c_prefs = {{1, 0}, {0, 1}};
44 vector<int> expected_matches = {1, 0};
45 ASSERT_EQ(sol.
match(s2c, c2s), expected_matches);
48 TEST(StableMatchingTest, Wikipedia3x3Example) {
60 vector<vector<int>> s_prefs = {{1, 0, 2}, {2, 1, 0}, {0, 2, 1}};
61 vector<vector<int>> c_prefs = {{1, 0, 2}, {2, 1, 0}, {0, 2, 1}};
67 vector<int> expected_matches = {1, 2, 0};
68 ASSERT_EQ(sol.
match(s2c, c2s), expected_matches);
71 TEST(StableMatchingTest, MultiRound3x3) {
89 vector<vector<int>> s_prefs = {{0, 1, 2}, {1, 0, 2}, {0, 1, 2}};
90 vector<vector<int>> c_prefs = {{1, 2, 0}, {0, 1, 2}, {0, 1, 2}};
96 vector<int> expected_matches = {1, 0, 2};
97 ASSERT_EQ(sol.
match(s2c, c2s), expected_matches);
100 TEST(StableMatchingTest, WorstCaseForStudents) {
112 vector<vector<int>> s_prefs = {{0, 1}, {0, 1}};
113 vector<vector<int>> c_prefs = {{1, 0}, {1, 0}};
119 vector<int> expected_matches = {1, 0};
120 ASSERT_EQ(sol.
match(s2c, c2s), expected_matches);