Documentation for 341ed50da8

This commit is contained in:
github-actions
2021-09-03 19:56:17 +00:00
parent 52d0c55145
commit 08e8eb037e
3432 changed files with 71392 additions and 72953 deletions

View File

@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: graph/hopcroft_karp.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -17,9 +17,9 @@
<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"],
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</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>
@@ -32,8 +32,7 @@
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C++
&#160;<span id="projectnumber">1.0.0</span>
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
</td>
@@ -42,21 +41,22 @@
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search','.html');
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
@@ -70,7 +70,7 @@ $(function() {
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('d1/d9a/hopcroft__karp_8cpp.html','../../'); initResizable(); });
/* @license-end */
</script>
@@ -94,12 +94,11 @@ $(document).ready(function(){initNavTree('d1/d9a/hopcroft__karp_8cpp.html','../.
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">hopcroft_karp.cpp File Reference</div> </div>
<div class="headertitle"><div class="title">hopcroft_karp.cpp File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Implementation of <a href="https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm">HopcroftKarp</a> algorithm.
<p>Implementation of <a href="https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm" target="_blank">HopcroftKarp</a> algorithm.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;iostream&gt;</code><br />
<code>#include &lt;cstdlib&gt;</code><br />
@@ -115,19 +114,19 @@ Include dependency graph for hopcroft_karp.cpp:</div>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d69/classgraph_1_1_h_k_graph.html">graph::HKGraph</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Represents Bipartite graph for Hopcroft Karp implementation. <a href="../../d8/d69/classgraph_1_1_h_k_graph.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:df/dce/namespacegraph"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dce/namespacegraph.html">graph</a></td></tr>
<tr class="memitem:df/dce/namespacegraph"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dce/namespacegraph.html">graph</a></td></tr>
<tr class="memdesc:df/dce/namespacegraph"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="../../dc/d61/classgraph_1_1_graph.html">Graph</a> Algorithms. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a88ec9ad42717780d6caaff9d3d6977f9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d9a/hopcroft__karp_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9">tests</a> ()</td></tr>
<tr class="separator:a88ec9ad42717780d6caaff9d3d6977f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
@@ -136,29 +135,29 @@ Functions</h2></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Implementation of <a href="https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm">HopcroftKarp</a> algorithm. </p>
<p>The HopcroftKarp algorithm is an algorithm that takes as input a bipartite graph and produces as output a maximum cardinality matching, it runs in O(E√V) time in worst case.</p>
<div class="textblock"><p >Implementation of <a href="https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm" target="_blank">HopcroftKarp</a> algorithm. </p>
<p >The HopcroftKarp algorithm is an algorithm that takes as input a bipartite graph and produces as output a maximum cardinality matching, it runs in O(E√V) time in worst case.</p>
<h3><a class="anchor" id="autotoc_md67"></a>
Bipartite graph</h3>
<p>A bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint and independent sets U and V such that every edge connects a vertex in U to one in V. Vertex sets U and V are usually called the parts of the graph. Equivalently, a bipartite graph is a graph that does not contain any odd-length cycles.</p>
<p >A bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint and independent sets U and V such that every edge connects a vertex in U to one in V. Vertex sets U and V are usually called the parts of the graph. Equivalently, a bipartite graph is a graph that does not contain any odd-length cycles.</p>
<h3><a class="anchor" id="autotoc_md68"></a>
Matching and Not-Matching edges</h3>
<p>Given a matching M, edges that are part of matching are called Matching edges and edges that are not part of M (or connect free nodes) are called Not-Matching edges.</p>
<p >Given a matching M, edges that are part of matching are called Matching edges and edges that are not part of M (or connect free nodes) are called Not-Matching edges.</p>
<h3><a class="anchor" id="autotoc_md69"></a>
Maximum cardinality matching</h3>
<p>Given a bipartite graphs G = ( V = ( X , Y ) , E ) whose partition has the parts X and Y, with E denoting the edges of the graph, the goal is to find a matching with as many edges as possible. Equivalently, a matching that covers as many vertices as possible.</p>
<p >Given a bipartite graphs G = ( V = ( X , Y ) , E ) whose partition has the parts X and Y, with E denoting the edges of the graph, the goal is to find a matching with as many edges as possible. Equivalently, a matching that covers as many vertices as possible.</p>
<h3><a class="anchor" id="autotoc_md70"></a>
Augmenting paths</h3>
<p>Given a matching M, an augmenting path is an alternating path that starts from and ends on free vertices. All single edge paths that start and end with free vertices are augmenting paths.</p>
<p >Given a matching M, an augmenting path is an alternating path that starts from and ends on free vertices. All single edge paths that start and end with free vertices are augmenting paths.</p>
<h3><a class="anchor" id="autotoc_md71"></a>
Concept</h3>
<p>A matching M is not maximum if there exists an augmenting path. It is also true other way, i.e, a matching is maximum if no augmenting path exists.</p>
<p >A matching M is not maximum if there exists an augmenting path. It is also true other way, i.e, a matching is maximum if no augmenting path exists.</p>
<h3><a class="anchor" id="autotoc_md72"></a>
Algorithm</h3>
<p>1) Initialize the Maximal Matching M as empty. 2) While there exists an Augmenting Path P Remove matching edges of P from M and add not-matching edges of P to M (This increases size of M by 1 as P starts and ends with a free vertex i.e. a node that is not part of matching.) 3) Return M.</p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Krishnapal4050">Krishna Pal Deora</a> </dd></dl>
<p >1) Initialize the Maximal Matching M as empty. 2) While there exists an Augmenting Path P Remove matching edges of P from M and add not-matching edges of P to M (This increases size of M by 1 as P starts and ends with a free vertex i.e. a node that is not part of matching.) 3) Return M.</p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Krishnapal4050" target="_blank">Krishna Pal Deora</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
@@ -176,25 +175,25 @@ Algorithm</h3>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a name="l00307"></a><span class="lineno"> 307</span>&#160;{</div>
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>&#160; <a class="code" href="../../d1/d9a/hopcroft__karp_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9">tests</a>(); <span class="comment">// perform self-tests</span></div>
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>&#160; </div>
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>&#160; <span class="keywordtype">int</span> v1 = 0, v2 = 0, e = 0;</div>
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; v1 &gt;&gt; v2 &gt;&gt; e; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span>&#160; <a class="code" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g(v1, v2); </div>
<div class="line"><a name="l00313"></a><span class="lineno"> 313</span>&#160; <span class="keywordtype">int</span> u = 0, v = 0;</div>
<div class="line"><a name="l00314"></a><span class="lineno"> 314</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; e; ++i)</div>
<div class="line"><a name="l00315"></a><span class="lineno"> 315</span>&#160; {</div>
<div class="line"><a name="l00316"></a><span class="lineno"> 316</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; u &gt;&gt; v;</div>
<div class="line"><a name="l00317"></a><span class="lineno"> 317</span>&#160; g.addEdge(u, v);</div>
<div class="line"><a name="l00318"></a><span class="lineno"> 318</span>&#160; }</div>
<div class="line"><a name="l00319"></a><span class="lineno"> 319</span>&#160; </div>
<div class="line"><a name="l00320"></a><span class="lineno"> 320</span>&#160; <span class="keywordtype">int</span> res = g.hopcroftKarpAlgorithm();</div>
<div class="line"><a name="l00321"></a><span class="lineno"> 321</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Maximum matching is &quot;</span> &lt;&lt; res &lt;&lt;<span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a name="l00322"></a><span class="lineno"> 322</span>&#160; </div>
<div class="line"><a name="l00323"></a><span class="lineno"> 323</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00324"></a><span class="lineno"> 324</span>&#160; </div>
<div class="line"><a name="l00325"></a><span class="lineno"> 325</span>&#160;}</div>
<div class="fragment"><div class="line"><a id="l00307" name="l00307"></a><span class="lineno"> 307</span>{</div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno"> 308</span> <a class="code hl_function" href="../../d1/d9a/hopcroft__karp_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9">tests</a>(); <span class="comment">// perform self-tests</span></div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno"> 309</span> </div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno"> 310</span> <span class="keywordtype">int</span> v1 = 0, v2 = 0, e = 0;</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno"> 311</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; v1 &gt;&gt; v2 &gt;&gt; e; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno"> 312</span> <a class="code hl_class" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g(v1, v2); </div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno"> 313</span> <span class="keywordtype">int</span> u = 0, v = 0;</div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno"> 314</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; e; ++i)</div>
<div class="line"><a id="l00315" name="l00315"></a><span class="lineno"> 315</span> {</div>
<div class="line"><a id="l00316" name="l00316"></a><span class="lineno"> 316</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; u &gt;&gt; v;</div>
<div class="line"><a id="l00317" name="l00317"></a><span class="lineno"> 317</span> g.addEdge(u, v);</div>
<div class="line"><a id="l00318" name="l00318"></a><span class="lineno"> 318</span> }</div>
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno"> 319</span> </div>
<div class="line"><a id="l00320" name="l00320"></a><span class="lineno"> 320</span> <span class="keywordtype">int</span> res = g.hopcroftKarpAlgorithm();</div>
<div class="line"><a id="l00321" name="l00321"></a><span class="lineno"> 321</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Maximum matching is &quot;</span> &lt;&lt; res &lt;&lt;<span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00322" name="l00322"></a><span class="lineno"> 322</span> </div>
<div class="line"><a id="l00323" name="l00323"></a><span class="lineno"> 323</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00324" name="l00324"></a><span class="lineno"> 324</span> </div>
<div class="line"><a id="l00325" name="l00325"></a><span class="lineno"> 325</span>}</div>
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="aclassgraph_1_1_h_k_graph_html"><div class="ttname"><a href="../../d8/d69/classgraph_1_1_h_k_graph.html">graph::HKGraph</a></div><div class="ttdoc">Represents Bipartite graph for Hopcroft Karp implementation.</div><div class="ttdef"><b>Definition:</b> hopcroft_karp.cpp:67</div></div>
@@ -202,13 +201,13 @@ Algorithm</h3>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="100%" height="407"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="580" height="144"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a88ec9ad42717780d6caaff9d3d6977f9"></a>
<a id="a88ec9ad42717780d6caaff9d3d6977f9" name="a88ec9ad42717780d6caaff9d3d6977f9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a88ec9ad42717780d6caaff9d3d6977f9">&#9670;&nbsp;</a></span>tests()</h2>
<div class="memitem">
@@ -222,57 +221,57 @@ Here is the call graph for this function:</div>
</tr>
</table>
</div><div class="memdoc">
<p>Self-test implementation </p><dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
<div class="fragment"><div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; {</div>
<div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; <span class="comment">// Sample test case 1</span></div>
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; <span class="keywordtype">int</span> v1a = 3, v1b = 5, e1 = 2; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; <a class="code" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g1(v1a, v1b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; </div>
<div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; g1.addEdge(0,1);</div>
<div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; g1.addEdge(1,4);</div>
<div class="line"><a name="l00262"></a><span class="lineno"> 262</span>&#160; </div>
<div class="line"><a name="l00263"></a><span class="lineno"> 263</span>&#160; <span class="keywordtype">int</span> expected_res1 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a name="l00264"></a><span class="lineno"> 264</span>&#160; <span class="keywordtype">int</span> res1 = g1.hopcroftKarpAlgorithm();</div>
<div class="line"><a name="l00265"></a><span class="lineno"> 265</span>&#160; </div>
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160; assert(res1 == expected_res1); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 1</span></div>
<div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160; </div>
<div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160; <span class="comment">// Sample test case 2</span></div>
<div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160; <span class="keywordtype">int</span> v2a = 4, v2b = 4, e2 = 6; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; <a class="code" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g2(v2a, v2b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160; </div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; g2.addEdge(1,1);</div>
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160; g2.addEdge(1,3);</div>
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; g2.addEdge(2,3);</div>
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160; g2.addEdge(3,4);</div>
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span>&#160; g2.addEdge(4,3);</div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160; g2.addEdge(4,2);</div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160; </div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160; <span class="keywordtype">int</span> expected_res2 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160; <span class="keywordtype">int</span> res2 = g2.hopcroftKarpAlgorithm();</div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160; </div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160; assert(res2 == expected_res2); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 2</span></div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160; </div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; <span class="comment">// Sample test case 3</span></div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; <span class="keywordtype">int</span> v3a = 6, v3b = 6, e3 = 4; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; <a class="code" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g3(v3a, v3b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160; </div>
<div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160; g3.addEdge(0,1);</div>
<div class="line"><a name="l00289"></a><span class="lineno"> 289</span>&#160; g3.addEdge(1,4);</div>
<div class="line"><a name="l00290"></a><span class="lineno"> 290</span>&#160; g3.addEdge(1,5);</div>
<div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160; g3.addEdge(5,0);</div>
<div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160; </div>
<div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160; <span class="keywordtype">int</span> expected_res3 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160; <span class="keywordtype">int</span> res3 = g3.hopcroftKarpAlgorithm();</div>
<div class="line"><a name="l00295"></a><span class="lineno"> 295</span>&#160; </div>
<div class="line"><a name="l00296"></a><span class="lineno"> 296</span>&#160; assert(res3 == expected_res3); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 3</span></div>
<div class="line"><a name="l00297"></a><span class="lineno"> 297</span>&#160; </div>
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>&#160; </div>
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>&#160; </div>
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160;}</div>
<p >Self-test implementation </p><dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
<div class="fragment"><div class="line"><a id="l00255" name="l00255"></a><span class="lineno"> 255</span> {</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno"> 256</span> <span class="comment">// Sample test case 1</span></div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno"> 257</span> <span class="keywordtype">int</span> v1a = 3, v1b = 5, e1 = 2; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno"> 258</span> <a class="code hl_class" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g1(v1a, v1b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno"> 259</span> </div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno"> 260</span> g1.addEdge(0,1);</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno"> 261</span> g1.addEdge(1,4);</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno"> 262</span> </div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno"> 263</span> <span class="keywordtype">int</span> expected_res1 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno"> 264</span> <span class="keywordtype">int</span> res1 = g1.hopcroftKarpAlgorithm();</div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno"> 265</span> </div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno"> 266</span> assert(res1 == expected_res1); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 1</span></div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno"> 267</span> </div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno"> 268</span> <span class="comment">// Sample test case 2</span></div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span> <span class="keywordtype">int</span> v2a = 4, v2b = 4, e2 = 6; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno"> 270</span> <a class="code hl_class" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g2(v2a, v2b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno"> 271</span> </div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno"> 272</span> g2.addEdge(1,1);</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno"> 273</span> g2.addEdge(1,3);</div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"> 274</span> g2.addEdge(2,3);</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span> g2.addEdge(3,4);</div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"> 276</span> g2.addEdge(4,3);</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno"> 277</span> g2.addEdge(4,2);</div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno"> 278</span> </div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno"> 279</span> <span class="keywordtype">int</span> expected_res2 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno"> 280</span> <span class="keywordtype">int</span> res2 = g2.hopcroftKarpAlgorithm();</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno"> 281</span> </div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno"> 282</span> assert(res2 == expected_res2); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 2</span></div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno"> 283</span> </div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno"> 284</span> <span class="comment">// Sample test case 3</span></div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno"> 285</span> <span class="keywordtype">int</span> v3a = 6, v3b = 6, e3 = 4; <span class="comment">// vertices of left side, right side and edges</span></div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno"> 286</span> <a class="code hl_class" href="../../d8/d69/classgraph_1_1_h_k_graph.html">HKGraph</a> g3(v3a, v3b); <span class="comment">// execute the algorithm </span></div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno"> 287</span> </div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno"> 288</span> g3.addEdge(0,1);</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno"> 289</span> g3.addEdge(1,4);</div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno"> 290</span> g3.addEdge(1,5);</div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno"> 291</span> g3.addEdge(5,0);</div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno"> 292</span> </div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno"> 293</span> <span class="keywordtype">int</span> expected_res3 = 0; <span class="comment">// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno"> 294</span> <span class="keywordtype">int</span> res3 = g3.hopcroftKarpAlgorithm();</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno"> 295</span> </div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno"> 296</span> assert(res3 == expected_res3); <span class="comment">// assert check to ensure that the algorithm executed correctly for test 3</span></div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span> </div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno"> 298</span> </div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"> 299</span> </div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno"> 300</span>}</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="../../d1/d9a/hopcroft__karp_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg" width="655" height="143"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d9a/hopcroft__karp_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg" width="482" height="134"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
@@ -284,7 +283,7 @@ Here is the call graph for this function:</div>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li><li class="navelem"><a class="el" href="../../d1/d9a/hopcroft__karp_8cpp.html">hopcroft_karp.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.9.1 </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.9.2 </li>
</ul>
</div>
</body>