Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -1,3 +1,4 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
@@ -5,10 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: greedy_algorithms/gale_shapley.cpp File Reference</title>
<title>TheAlgorithms/C++: greedy_algorithms/gale_shapley.cpp File Reference</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
@@ -18,14 +24,24 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
@@ -122,7 +139,9 @@ Include dependency graph for gale_shapley.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/dab/gale__shapley_8cpp__incl.svg" width="339" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
</div>
<p><a href="../../db/d80/gale__shapley_8cpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d2/d90/namespacegreedy__algorithms.html">greedy_algorithms</a></td></tr>
@@ -134,7 +153,7 @@ Namespaces</h2></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6d7e84df47dcf19e88f95f8f9040306c" id="r_a6d7e84df47dcf19e88f95f8f9040306c"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> &gt; &gt; &amp;secondary_preferences, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> &gt; &gt; &amp;primary_preferences)</td></tr>
<tr class="memitem:a6d7e84df47dcf19e88f95f8f9040306c" id="r_a6d7e84df47dcf19e88f95f8f9040306c"><td class="memItemLeft" align="right" valign="top">std::vector&lt; std::uint32_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a> (const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;secondary_preferences, const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;primary_preferences)</td></tr>
<tr class="memdesc:a6d7e84df47dcf19e88f95f8f9040306c"><td class="mdescLeft">&#160;</td><td class="mdescRight">The main function that finds the stable matching between two sets of elements using the Gale-Shapley Algorithm. <br /></td></tr>
<tr class="separator:a6d7e84df47dcf19e88f95f8f9040306c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a483bb8ccf42aaf7375a83e91490eda1e" id="r_a483bb8ccf42aaf7375a83e91490eda1e"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a> ()</td></tr>
@@ -150,6 +169,8 @@ Functions</h2></td></tr>
<p><b>Gale Shapley Algorithm</b> aims to find a stable matching between two equally sized sets of elements given an ordinal preference for each element. The algorithm was introduced by David Gale and Lloyd Shapley in 1962.</p>
<p>Reference: <a href="https://en.wikipedia.org/wiki/Gale%E2%80%93Shapley_algorithm" target="_blank">Wikipedia</a> <a href="https://en.wikipedia.org/wiki/Stable_matching_problem" target="_blank">Wikipedia</a></p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/BKarthik7" target="_blank">B Karthik</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../db/d80/gale__shapley_8cpp_source.html">gale_shapley.cpp</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&#160;</a></span>main()</h2>
@@ -168,17 +189,14 @@ Functions</h2></td></tr>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../db/d80/gale__shapley_8cpp_source.html#l00152">152</a> of file <a class="el" href="../../db/d80/gale__shapley_8cpp_source.html">gale_shapley.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 152</span> {</div>
<div class="line"><span class="lineno"> 153</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self-test implementations</span></div>
<div class="line"><span class="lineno"> 154</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 155</span>}</div>
<div class="ttc" id="agale__shapley_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> gale_shapley.cpp:114</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d80/gale__shapley_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="471" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="agale__shapley_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> <a href="../../db/d80/gale__shapley_8cpp_source.html#l00114">gale_shapley.cpp:114</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a483bb8ccf42aaf7375a83e91490eda1e" name="a483bb8ccf42aaf7375a83e91490eda1e"></a>
@@ -206,15 +224,17 @@ Here is the call graph for this function:</div>
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../db/d80/gale__shapley_8cpp_source.html#l00114">114</a> of file <a class="el" href="../../db/d80/gale__shapley_8cpp_source.html">gale_shapley.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 114</span> {</div>
<div class="line"><span class="lineno"> 115</span> <span class="comment">// Test Case 1</span></div>
<div class="line"><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;std::uint32_t&gt;</a>&gt; primary_preferences = {</div>
<div class="line"><span class="lineno"> 116</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt; primary_preferences = {</div>
<div class="line"><span class="lineno"> 117</span> {0, 1, 2, 3}, {2, 1, 3, 0}, {1, 2, 0, 3}, {3, 0, 1, 2}};</div>
<div class="line"><span class="lineno"> 118</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;std::uint32_t&gt;</a>&gt; secondary_preferences = {</div>
<div class="line"><span class="lineno"> 118</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt; secondary_preferences = {</div>
<div class="line"><span class="lineno"> 119</span> {1, 0, 2, 3}, {3, 0, 1, 2}, {0, 2, 1, 3}, {1, 2, 0, 3}};</div>
<div class="line"><span class="lineno"> 120</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><span class="lineno"> 121</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><span class="lineno"> 122</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint32_t&gt;</a>({0, 2, 1, 3}));</div>
<div class="line"><span class="lineno"> 122</span> std::vector&lt;std::uint32_t&gt;({0, 2, 1, 3}));</div>
<div class="line"><span class="lineno"> 123</span> </div>
<div class="line"><span class="lineno"> 124</span> <span class="comment">// Test Case 2</span></div>
<div class="line"><span class="lineno"> 125</span> primary_preferences = {</div>
@@ -223,30 +243,24 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 128</span> {1, 0, 2, 3}, {3, 0, 1, 2}, {0, 2, 1, 3}, {1, 2, 0, 3}};</div>
<div class="line"><span class="lineno"> 129</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><span class="lineno"> 130</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><span class="lineno"> 131</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint32_t&gt;</a>({0, 3, 1, 2}));</div>
<div class="line"><span class="lineno"> 131</span> std::vector&lt;std::uint32_t&gt;({0, 3, 1, 2}));</div>
<div class="line"><span class="lineno"> 132</span> </div>
<div class="line"><span class="lineno"> 133</span> <span class="comment">// Test Case 3</span></div>
<div class="line"><span class="lineno"> 134</span> primary_preferences = {{0, 1, 2}, {2, 1, 0}, {1, 2, 0}};</div>
<div class="line"><span class="lineno"> 135</span> secondary_preferences = {{1, 0, 2}, {2, 0, 1}, {0, 2, 1}};</div>
<div class="line"><span class="lineno"> 136</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><span class="lineno"> 137</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><span class="lineno"> 138</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint32_t&gt;</a>({0, 2, 1}));</div>
<div class="line"><span class="lineno"> 138</span> std::vector&lt;std::uint32_t&gt;({0, 2, 1}));</div>
<div class="line"><span class="lineno"> 139</span> </div>
<div class="line"><span class="lineno"> 140</span> <span class="comment">// Test Case 4</span></div>
<div class="line"><span class="lineno"> 141</span> primary_preferences = {};</div>
<div class="line"><span class="lineno"> 142</span> secondary_preferences = {};</div>
<div class="line"><span class="lineno"> 143</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><span class="lineno"> 144</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><span class="lineno"> 145</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint32_t&gt;</a>({}));</div>
<div class="line"><span class="lineno"> 145</span> std::vector&lt;std::uint32_t&gt;({}));</div>
<div class="line"><span class="lineno"> 146</span>}</div>
<div class="ttc" id="anamespacegreedy__algorithms_1_1stable__matching_html_a6d7e84df47dcf19e88f95f8f9040306c"><div class="ttname"><a href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a></div><div class="ttdeci">std::vector&lt; std::uint32_t &gt; gale_shapley(const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;secondary_preferences, const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;primary_preferences)</div><div class="ttdoc">The main function that finds the stable matching between two sets of elements using the Gale-Shapley ...</div><div class="ttdef"><b>Definition</b> gale_shapley.cpp:46</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d80/gale__shapley_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg" width="374" height="67"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="anamespacegreedy__algorithms_1_1stable__matching_html_a6d7e84df47dcf19e88f95f8f9040306c"><div class="ttname"><a href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a></div><div class="ttdeci">std::vector&lt; std::uint32_t &gt; gale_shapley(const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;secondary_preferences, const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;primary_preferences)</div><div class="ttdoc">The main function that finds the stable matching between two sets of elements using the Gale-Shapley ...</div><div class="ttdef"><b>Definition</b> <a href="../../db/d80/gale__shapley_8cpp_source.html#l00046">gale_shapley.cpp:46</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->

View File

@@ -1,7 +0,0 @@
<map id="tests" name="tests">
<area shape="rect" id="Node000001" title="Self&#45;test implementations." alt="" coords="5,20,56,46"/>
<area shape="rect" id="Node000002" href="$dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ..." alt="" coords="104,5,252,61"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="56,30,88,30,88,36,56,36"/>
<area shape="rect" id="Node000003" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/find.html#" title=" " alt="" coords="300,20,368,46"/>
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="252,30,284,30,284,36,252,36"/>
</map>

View File

@@ -1 +0,0 @@
10eb6585cdd9e9d606f67df39451ea7a

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: tests Pages: 1 -->
<svg width="280pt" height="50pt"
viewBox="0.00 0.00 280.25 49.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 45.75)">
<title>tests</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="Self&#45;test implementations.">
<polygon fill="#999999" stroke="#666666" points="37.75,-30.5 0,-30.5 0,-11.25 37.75,-11.25 37.75,-30.5"/>
<text text-anchor="middle" x="18.88" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" target="_top" xlink:title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ...">
<polygon fill="white" stroke="#666666" points="185,-41.75 73.75,-41.75 73.75,0 185,0 185,-41.75"/>
<text text-anchor="start" x="81.75" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">greedy_algorithms::</text>
<text text-anchor="start" x="81.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">stable_matching::gale</text>
<text text-anchor="middle" x="129.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">_shapley</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M37.79,-20.88C44.73,-20.88 53.14,-20.88 62.01,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.89,-24.38 71.89,-20.88 61.89,-17.38 61.89,-24.38"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/find.html#" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="272.25,-30.5 221,-30.5 221,-11.25 272.25,-11.25 272.25,-30.5"/>
<text text-anchor="middle" x="246.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::find</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M185.3,-20.88C193.44,-20.88 201.66,-20.88 209.29,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="209.2,-24.38 219.2,-20.88 209.2,-17.38 209.2,-24.38"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: tests Pages: 1 -->
<svg width="280pt" height="50pt"
viewBox="0.00 0.00 280.25 49.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 45.75)">
<title>tests</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="Self&#45;test implementations.">
<polygon fill="#999999" stroke="#666666" points="37.75,-30.5 0,-30.5 0,-11.25 37.75,-11.25 37.75,-30.5"/>
<text text-anchor="middle" x="18.88" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" target="_top" xlink:title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ...">
<polygon fill="white" stroke="#666666" points="185,-41.75 73.75,-41.75 73.75,0 185,0 185,-41.75"/>
<text text-anchor="start" x="81.75" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">greedy_algorithms::</text>
<text text-anchor="start" x="81.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">stable_matching::gale</text>
<text text-anchor="middle" x="129.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">_shapley</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M37.79,-20.88C44.73,-20.88 53.14,-20.88 62.01,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.89,-24.38 71.89,-20.88 61.89,-17.38 61.89,-24.38"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/find.html#" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="272.25,-30.5 221,-30.5 221,-11.25 272.25,-11.25 272.25,-30.5"/>
<text text-anchor="middle" x="246.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::find</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M185.3,-20.88C193.44,-20.88 201.66,-20.88 209.29,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="209.2,-24.38 219.2,-20.88 209.2,-17.38 209.2,-24.38"/>
</a>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -1,9 +0,0 @@
<map id="main" name="main">
<area shape="rect" id="Node000001" title="Main function." alt="" coords="5,20,55,46"/>
<area shape="rect" id="Node000002" href="$db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" title="Self&#45;test implementations." alt="" coords="103,20,153,46"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="55,30,88,30,88,36,55,36"/>
<area shape="rect" id="Node000003" href="$dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ..." alt="" coords="201,5,349,61"/>
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="153,30,185,30,185,36,153,36"/>
<area shape="rect" id="Node000004" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/find.html#" title=" " alt="" coords="397,20,466,46"/>
<area shape="poly" id="edge3_Node000003_Node000004" title=" " alt="" coords="350,30,382,30,382,36,350,36"/>
</map>

View File

@@ -1 +0,0 @@
57ab2bbadab7072265c0260236c9486c

View File

@@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: main Pages: 1 -->
<svg width="353pt" height="50pt"
viewBox="0.00 0.00 353.25 49.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 45.75)">
<title>main</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="Main function.">
<polygon fill="#999999" stroke="#666666" points="37,-30.5 0,-30.5 0,-11.25 37,-11.25 37,-30.5"/>
<text text-anchor="middle" x="18.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title="Self&#45;test implementations.">
<polygon fill="white" stroke="#666666" points="110.75,-30.5 73,-30.5 73,-11.25 110.75,-11.25 110.75,-30.5"/>
<text text-anchor="middle" x="91.88" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M37.14,-20.88C44.55,-20.88 53.37,-20.88 61.69,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.43,-24.38 71.43,-20.88 61.43,-17.38 61.43,-24.38"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" target="_top" xlink:title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ...">
<polygon fill="white" stroke="#666666" points="258,-41.75 146.75,-41.75 146.75,0 258,0 258,-41.75"/>
<text text-anchor="start" x="154.75" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">greedy_algorithms::</text>
<text text-anchor="start" x="154.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">stable_matching::gale</text>
<text text-anchor="middle" x="202.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">_shapley</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M110.79,-20.88C117.73,-20.88 126.14,-20.88 135.01,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.89,-24.38 144.89,-20.88 134.89,-17.38 134.89,-24.38"/>
</a>
</g>
</g>
<!-- Node4 -->
<g id="Node000004" class="node">
<title>Node4</title>
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/find.html#" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="345.25,-30.5 294,-30.5 294,-11.25 345.25,-11.25 345.25,-30.5"/>
<text text-anchor="middle" x="319.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::find</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node4 -->
<g id="edge3_Node000003_Node000004" class="edge">
<title>Node3&#45;&gt;Node4</title>
<g id="a_edge3_Node000003_Node000004"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M258.3,-20.88C266.44,-20.88 274.66,-20.88 282.29,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="282.2,-24.38 292.2,-20.88 282.2,-17.38 282.2,-24.38"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: main Pages: 1 -->
<svg width="353pt" height="50pt"
viewBox="0.00 0.00 353.25 49.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 45.75)">
<title>main</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="Main function.">
<polygon fill="#999999" stroke="#666666" points="37,-30.5 0,-30.5 0,-11.25 37,-11.25 37,-30.5"/>
<text text-anchor="middle" x="18.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title="Self&#45;test implementations.">
<polygon fill="white" stroke="#666666" points="110.75,-30.5 73,-30.5 73,-11.25 110.75,-11.25 110.75,-30.5"/>
<text text-anchor="middle" x="91.88" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M37.14,-20.88C44.55,-20.88 53.37,-20.88 61.69,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.43,-24.38 71.43,-20.88 61.43,-17.38 61.43,-24.38"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c" target="_top" xlink:title="The main function that finds the stable matching between two sets of elements using the Gale&#45;Shapley ...">
<polygon fill="white" stroke="#666666" points="258,-41.75 146.75,-41.75 146.75,0 258,0 258,-41.75"/>
<text text-anchor="start" x="154.75" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">greedy_algorithms::</text>
<text text-anchor="start" x="154.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">stable_matching::gale</text>
<text text-anchor="middle" x="202.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">_shapley</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M110.79,-20.88C117.73,-20.88 126.14,-20.88 135.01,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.89,-24.38 144.89,-20.88 134.89,-17.38 134.89,-24.38"/>
</a>
</g>
</g>
<!-- Node4 -->
<g id="Node000004" class="node">
<title>Node4</title>
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/find.html#" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="345.25,-30.5 294,-30.5 294,-11.25 345.25,-11.25 345.25,-30.5"/>
<text text-anchor="middle" x="319.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::find</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node4 -->
<g id="edge3_Node000003_Node000004" class="edge">
<title>Node3&#45;&gt;Node4</title>
<g id="a_edge3_Node000003_Node000004"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M258.3,-20.88C266.44,-20.88 274.66,-20.88 282.29,-20.88"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="282.2,-24.38 292.2,-20.88 282.2,-17.38 282.2,-24.38"/>
</a>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,259 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: greedy_algorithms/gale_shapley.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('db/d80/gale__shapley_8cpp_source.html','../../'); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">gale_shapley.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../db/d80/gale__shapley_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#include &lt;algorithm&gt;</span> </div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#include &lt;cassert&gt;</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="preprocessor">#include &lt;cstdint&gt;</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="preprocessor">#include &lt;vector&gt;</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../d2/d90/namespacegreedy__algorithms.html">greedy_algorithms</a> {</div>
<div class="foldopen" id="foldopen00034" data-start="{" data-end="}">
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"><a class="line" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html"> 34</a></span><span class="keyword">namespace </span>stable_matching {</div>
<div class="foldopen" id="foldopen00046" data-start="{" data-end="}">
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c"> 46</a></span>std::vector&lt;std::uint32_t&gt; <a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">gale_shapley</a>(</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keyword">const</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt;&amp; secondary_preferences,</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <span class="keyword">const</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt;&amp; primary_preferences) {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> std::uint32_t num_elements = secondary_preferences.size();</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> std::vector&lt;std::uint32_t&gt; matches(num_elements, -1);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> std::vector&lt;bool&gt; is_free_primary(num_elements, <span class="keyword">true</span>);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> std::vector&lt;std::uint32_t&gt; proposal_index(</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> num_elements,</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> 0); <span class="comment">// Tracks the next secondary to propose for each primary</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="keywordflow">while</span> (<span class="keyword">true</span>) {</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordtype">int</span> free_primary_index = -1;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="comment">// Find the next free primary</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">for</span> (std::uint32_t i = 0; i &lt; num_elements; i++) {</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordflow">if</span> (is_free_primary[i]) {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> free_primary_index = i;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> }</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> }</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// If no free primary is found, break the loop</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="keywordflow">if</span> (free_primary_index == -1)</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="comment">// Get the next secondary to propose</span></div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> std::uint32_t secondary_to_propose =</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> primary_preferences[free_primary_index]</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> [proposal_index[free_primary_index]];</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> proposal_index[free_primary_index]++;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="comment">// Get the current match of the secondary</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> std::uint32_t current_match = matches[secondary_to_propose];</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// If the secondary is free, match them</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="keywordflow">if</span> (current_match == -1) {</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> matches[secondary_to_propose] = free_primary_index;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> is_free_primary[free_primary_index] = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="comment">// Determine if the current match should be replaced</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="keyword">auto</span> new_proposer_rank =</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> std::find(secondary_preferences[secondary_to_propose].begin(),</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> secondary_preferences[secondary_to_propose].end(),</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> free_primary_index);</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> <span class="keyword">auto</span> current_match_rank =</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> std::find(secondary_preferences[secondary_to_propose].begin(),</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> secondary_preferences[secondary_to_propose].end(),</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> current_match);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="comment">// If the new proposer is preferred over the current match</span></div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">if</span> (new_proposer_rank &lt; current_match_rank) {</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> matches[secondary_to_propose] = free_primary_index;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> is_free_primary[free_primary_index] = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> is_free_primary[current_match] =</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <span class="keyword">true</span>; <span class="comment">// Current match is now free</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> }</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> }</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> }</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="keywordflow">return</span> matches;</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span>}</div>
</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span>} <span class="comment">// namespace stable_matching</span></div>
</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span>} <span class="comment">// namespace greedy_algorithms</span></div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> </div>
<div class="foldopen" id="foldopen00114" data-start="{" data-end="}">
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"><a class="line" href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e"> 114</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>() {</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="comment">// Test Case 1</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt; primary_preferences = {</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> {0, 1, 2, 3}, {2, 1, 3, 0}, {1, 2, 0, 3}, {3, 0, 1, 2}};</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> std::vector&lt;std::vector&lt;std::uint32_t&gt;&gt; secondary_preferences = {</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> {1, 0, 2, 3}, {3, 0, 1, 2}, {0, 2, 1, 3}, {1, 2, 0, 3}};</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> std::vector&lt;std::uint32_t&gt;({0, 2, 1, 3}));</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> </div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="comment">// Test Case 2</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> primary_preferences = {</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> {0, 2, 1, 3}, {2, 3, 0, 1}, {3, 1, 2, 0}, {2, 1, 0, 3}};</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> secondary_preferences = {</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> {1, 0, 2, 3}, {3, 0, 1, 2}, {0, 2, 1, 3}, {1, 2, 0, 3}};</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> std::vector&lt;std::uint32_t&gt;({0, 3, 1, 2}));</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> </div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="comment">// Test Case 3</span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> primary_preferences = {{0, 1, 2}, {2, 1, 0}, {1, 2, 0}};</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> secondary_preferences = {{1, 0, 2}, {2, 0, 1}, {0, 2, 1}};</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> std::vector&lt;std::uint32_t&gt;({0, 2, 1}));</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> </div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> <span class="comment">// Test Case 4</span></div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> primary_preferences = {};</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> secondary_preferences = {};</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> assert(<a class="code hl_function" href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a>(</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> secondary_preferences, primary_preferences) ==</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> std::vector&lt;std::uint32_t&gt;({}));</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span>}</div>
</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> </div>
<div class="foldopen" id="foldopen00152" data-start="{" data-end="}">
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"><a class="line" href="../../db/d80/gale__shapley_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 152</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../db/d80/gale__shapley_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <a class="code hl_function" href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self-test implementations</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span>}</div>
</div>
<div class="ttc" id="agale__shapley_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="../../db/d80/gale__shapley_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> <a href="#l00114">gale_shapley.cpp:114</a></div></div>
<div class="ttc" id="agale__shapley_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../db/d80/gale__shapley_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Main function.</div><div class="ttdef"><b>Definition</b> <a href="#l00152">gale_shapley.cpp:152</a></div></div>
<div class="ttc" id="anamespacegreedy__algorithms_1_1stable__matching_html_a6d7e84df47dcf19e88f95f8f9040306c"><div class="ttname"><a href="../../dd/d9a/namespacegreedy__algorithms_1_1stable__matching.html#a6d7e84df47dcf19e88f95f8f9040306c">greedy_algorithms::stable_matching::gale_shapley</a></div><div class="ttdeci">std::vector&lt; std::uint32_t &gt; gale_shapley(const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;secondary_preferences, const std::vector&lt; std::vector&lt; std::uint32_t &gt; &gt; &amp;primary_preferences)</div><div class="ttdoc">The main function that finds the stable matching between two sets of elements using the Gale-Shapley ...</div><div class="ttdef"><b>Definition</b> <a href="#l00046">gale_shapley.cpp:46</a></div></div>
<div class="ttc" id="anamespacegreedy__algorithms_html"><div class="ttname"><a href="../../d2/d90/namespacegreedy__algorithms.html">greedy_algorithms</a></div><div class="ttdoc">for string class</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d1f/binary__addition_8cpp_source.html#l00027">binary_addition.cpp:27</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_0eaa691bd54ab0922ca7f50599de6d22.html">greedy_algorithms</a></li><li class="navelem"><a class="el" href="../../db/d80/gale__shapley_8cpp.html">gale_shapley.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
</ul>
</div>
</body>
</html>