mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-26 06:41:48 +08:00
Documentation for f1eddf4d65
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<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.13.2"/>
|
||||
<meta name="generator" content="Doxygen 1.14.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: graph/hamiltons_cycle.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
@@ -19,7 +19,6 @@
|
||||
<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>
|
||||
@@ -60,26 +59,20 @@ window.MathJax = {
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.13.2 -->
|
||||
<!-- Generated by Doxygen 1.14.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() { codefold.init(1); });
|
||||
/* @license-end */
|
||||
$(function() { codefold.init(); });
|
||||
</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&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 -->
|
||||
@@ -94,10 +87,9 @@ $(function() {
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('dd/d0c/hamiltons__cycle_8cpp.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
$(function(){initNavTree('dd/d0c/hamiltons__cycle_8cpp.html','../../',''); });
|
||||
</script>
|
||||
<div id="container">
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
@@ -121,8 +113,6 @@ $(function(){initNavTree('dd/d0c/hamiltons__cycle_8cpp.html','../../'); initResi
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="summary">
|
||||
<a href="#func-members">Functions</a> </div>
|
||||
<div class="headertitle"><div class="title">hamiltons_cycle.cpp File Reference</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
@@ -135,34 +125,29 @@ $(function(){initNavTree('dd/d0c/hamiltons__cycle_8cpp.html','../../'); initResi
|
||||
</div><div class="textblock"><div class="dynheader">
|
||||
Include dependency graph for hamiltons_cycle.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d59/hamiltons__cycle_8cpp__incl.svg" width="252" height="111"><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" loading="lazy" frameborder="0" src="../../dd/d59/hamiltons__cycle_8cpp__incl.svg" width="252" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div>
|
||||
<p><a href="../../dd/d0c/hamiltons__cycle_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="func-members" name="func-members"></a>
|
||||
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:abcf824e347eecfeeb69ea0280f34f3e4" id="r_abcf824e347eecfeeb69ea0280f34f3e4"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> (const std::vector< std::vector< bool > > &routes)</td></tr>
|
||||
<tr class="separator:abcf824e347eecfeeb69ea0280f34f3e4"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ae7880ce913f3058a35ff106d5be9e243" id="r_ae7880ce913f3058a35ff106d5be9e243"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#ae7880ce913f3058a35ff106d5be9e243">test1</a> ()</td></tr>
|
||||
<tr class="separator:ae7880ce913f3058a35ff106d5be9e243"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a45d94ead4cf4e1ff9f87c38bc99f59ae" id="r_a45d94ead4cf4e1ff9f87c38bc99f59ae"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a45d94ead4cf4e1ff9f87c38bc99f59ae">test2</a> ()</td></tr>
|
||||
<tr class="separator:a45d94ead4cf4e1ff9f87c38bc99f59ae"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a0cc94918b6831f308d4fe4fa27f08299" id="r_a0cc94918b6831f308d4fe4fa27f08299"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0cc94918b6831f308d4fe4fa27f08299">test3</a> ()</td></tr>
|
||||
<tr class="separator:a0cc94918b6831f308d4fe4fa27f08299"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a3c04138a5bfe5d72780bb7e82a18e627" id="r_a3c04138a5bfe5d72780bb7e82a18e627"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a3c04138a5bfe5d72780bb7e82a18e627">main</a> (int argc, char **argv)</td></tr>
|
||||
<tr class="separator:a3c04138a5bfe5d72780bb7e82a18e627"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>The implementation of <a href="https://en.wikipedia.org/wiki/Hamiltonian_path" target="_blank">Hamilton's cycle</a> dynamic solution for vertices number less than 20. </p>
|
||||
<p>I use \(2^n\times n\) matrix and for every \([i, j]\) ( \(i < 2^n\) and \(j < n\)) in the matrix I store <code>true</code> if it is possible to get to all vertices on which position in <code>i</code>'s binary representation is <code>1</code> so as \(j\) would be the last one.</p>
|
||||
<p>In the the end if any cell in \((2^n - 1)^{\mbox{th}}\) row is <code>true</code> there exists hamiltonian cycle.</p>
|
||||
<p>I use \(2^n\times n\) matrix and for every \([i, j]\) ( \(i < 2^n\) and \(j < n\)) in the matrix I store <span class="tt">true</span> if it is possible to get to all vertices on which position in <span class="tt">i</span>'s binary representation is <span class="tt">1</span> so as \(j\) would be the last one.</p>
|
||||
<p>In the the end if any cell in \((2^n - 1)^{\mbox{th}}\) row is <span class="tt">true</span> there exists hamiltonian cycle.</p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/vakhokoto" target="_blank">vakhokoto</a> </dd>
|
||||
<dd>
|
||||
<a href="https://github.com/kvedala" target="_blank">Krishna Vedala</a> </dd></dl>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html">hamiltons_cycle.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
</div><a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
|
||||
<a id="abcf824e347eecfeeb69ea0280f34f3e4" name="abcf824e347eecfeeb69ea0280f34f3e4"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#abcf824e347eecfeeb69ea0280f34f3e4">◆ </a></span>hamilton_cycle()</h2>
|
||||
|
||||
@@ -180,13 +165,13 @@ Functions</h2></td></tr>
|
||||
<p>The function determines if there is a hamilton's cycle in the graph</p>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">routes</td><td>nxn boolean matrix of \([i, j]\) where \([i, j]\) is <code>true</code> if there is a road from \(i\) to \(j\) </td></tr>
|
||||
<tr><td class="paramname">routes</td><td>nxn boolean matrix of \([i, j]\) where \([i, j]\) is <span class="tt">true</span> if there is a road from \(i\) to \(j\) </td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if there is Hamiltonian cycle in the graph </dd>
|
||||
<dl class="section return"><dt>Returns</dt><dd><span class="tt">true</span> if there is Hamiltonian cycle in the graph </dd>
|
||||
<dd>
|
||||
<code>false</code> if there is no Hamiltonian cycle in the graph </dd></dl>
|
||||
<span class="tt">false</span> if there is no Hamiltonian cycle in the graph </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html#l00030">30</a> of file <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html">hamiltons_cycle.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 30</span> {</div>
|
||||
@@ -289,7 +274,7 @@ Functions</h2></td></tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">static void test1 </td>
|
||||
<td class="memname">void test1 </td>
|
||||
<td>(</td>
|
||||
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
|
||||
<td></td>
|
||||
@@ -301,7 +286,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <code>true</code> for graph: <code>1 -> 2 -> 3 -> 4</code> </p><dl class="section return"><dt>Returns</dt><dd>None </dd></dl>
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <span class="tt">true</span> for graph: <span class="tt">1 -> 2 -> 3 -> 4</span> </p><dl class="section return"><dt>Returns</dt><dd>None </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html#l00081">81</a> of file <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html">hamiltons_cycle.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 81</span> {</div>
|
||||
@@ -330,7 +315,7 @@ Functions</h2></td></tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">static void test2 </td>
|
||||
<td class="memname">void test2 </td>
|
||||
<td>(</td>
|
||||
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
|
||||
<td></td>
|
||||
@@ -342,7 +327,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <code>false</code> for <br />
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <span class="tt">false</span> for <br />
|
||||
graph:</p><pre>
|
||||
1 -> 2 -> 3
|
||||
|
|
||||
@@ -376,7 +361,7 @@ Functions</h2></td></tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">static void test3 </td>
|
||||
<td class="memname">void test3 </td>
|
||||
<td>(</td>
|
||||
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
|
||||
<td></td>
|
||||
@@ -388,7 +373,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <code>true</code> for clique with 4 vertices </p><dl class="section return"><dt>Returns</dt><dd>None </dd></dl>
|
||||
<p>this test is testing if <a class="el" href="#abcf824e347eecfeeb69ea0280f34f3e4">hamilton_cycle</a> returns <span class="tt">true</span> for clique with 4 vertices </p><dl class="section return"><dt>Returns</dt><dd>None </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html#l00122">122</a> of file <a class="el" href="../../dd/d0c/hamiltons__cycle_8cpp_source.html">hamiltons_cycle.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 122</span> {</div>
|
||||
@@ -409,11 +394,19 @@ Functions</h2></td></tr>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<div id="page-nav" class="page-nav-panel">
|
||||
<div id="page-nav-resize-handle"></div>
|
||||
<div id="page-nav-tree">
|
||||
<div id="page-nav-contents">
|
||||
</div><!-- page-nav-contents -->
|
||||
</div><!-- page-nav-tree -->
|
||||
</div><!-- page-nav -->
|
||||
</div><!-- container -->
|
||||
<!-- start footer part -->
|
||||
<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="../../dd/d0c/hamiltons__cycle_8cpp.html">hamiltons_cycle.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.13.2 </li>
|
||||
<li class="navelem"><a href="../../dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li><li class="navelem"><a href="../../dd/d0c/hamiltons__cycle_8cpp.html">hamiltons_cycle.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.14.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user