Skip to content

Commit bb17cb8

Browse files
committed
function description
1 parent 272e366 commit bb17cb8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

greedy_algorithms/gale_shapley.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ namespace greedy_algorithms {
2929
* @namespace
3030
* @brief Functions for the Gale-Shapley Algorithm
3131
*/
32+
33+
/**
34+
* @brief The main function that finds the stable matching between two sets of elements
35+
* using the Gale-Shapley Algorithm.
36+
* @note This doesn't work on negative preferences. the preferences should be continuous integers starting from
37+
* 0 to number of preferences - 1.
38+
* @param primary_preferences the preferences of the primary set should be a 2D vector
39+
* @param secondary_preferences the preferences of the secondary set should be a 2D vector
40+
* @returns matches the stable matching between the two sets
41+
*/
42+
3243
namespace stable_matching {
3344
std::vector<int> gale_shapley(const std::vector<std::vector<int>>& secondary_preferences, const std::vector<std::vector<int>>& primary_preferences) {
3445
int num_elements = secondary_preferences.size();
@@ -84,7 +95,10 @@ std::vector<int> gale_shapley(const std::vector<std::vector<int>>& secondary_pre
8495
} // namespace stable_matching
8596
} // namespace greedy_algorithms
8697

87-
98+
/**
99+
* @brief Self-test implementations
100+
* @returns void
101+
*/
88102
static void tests() {
89103
// Test Case 1
90104
std::vector<std::vector<int>> primary_preferences = {{0, 1, 2, 3}, {2, 1, 3, 0}, {1, 2, 0, 3}, {3, 0, 1, 2}};

0 commit comments

Comments
 (0)