Documentation for c26eea874d

This commit is contained in:
realstealthninja
2025-05-19 11:38:33 +00:00
parent c7a9a42397
commit 14583a2f33
2829 changed files with 30266 additions and 21669 deletions

View File

@@ -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.12.0"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: graph/connected_components_with_dsu.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
@@ -60,7 +60,7 @@ window.MathJax = {
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
@@ -124,12 +124,12 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<div class="headertitle"><div class="title">connected_components_with_dsu.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../d8/d99/connected__components__with__dsu_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>
<a href="../../d8/d99/connected__components__with__dsu_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;cstdint&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#include &lt;iostream&gt;</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="preprocessor">#include &lt;set&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="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="../../df/dce/namespacegraph.html">graph</a> {</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../de/db4/namespacedisjoint__union.html">disjoint_union</a> {</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span>uint32_t number_of_nodes = 0; <span class="comment">// denotes number of nodes</span></div>
@@ -143,6 +143,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> }</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span>}</div>
</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span></div>
<div class="foldopen" id="foldopen00054" data-start="{" data-end="}">
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"><a class="line" href="../../d8/d99/connected__components__with__dsu_8cpp.html#a469384d8a4197a9b24482ce7c321a85e"> 54</a></span>int64_t <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#a469384d8a4197a9b24482ce7c321a85e">find_set</a>(int64_t val) {</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="keywordflow">while</span> (parent[val] != val) {</div>
@@ -152,6 +153,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keywordflow">return</span> val;</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span>}</div>
</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span></div>
<div class="foldopen" id="foldopen00067" data-start="{" data-end="}">
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"><a class="line" href="../../d8/d99/connected__components__with__dsu_8cpp.html#a67cb7472f310a798f555fe45cdf50145"> 67</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#a67cb7472f310a798f555fe45cdf50145">union_sets</a>(int64_t node1, int64_t node2) {</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> node1 = <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#a469384d8a4197a9b24482ce7c321a85e">find_set</a>(node1); <span class="comment">// find the parent of node1</span></div>
@@ -168,6 +170,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<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>}</div>
</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span></div>
<div class="foldopen" id="foldopen00085" data-start="{" data-end="}">
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"><a class="line" href="../../d8/d99/connected__components__with__dsu_8cpp.html#ac2d6698b71384a352ec4b81b31b13141"> 85</a></span>uint32_t <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#ac2d6698b71384a352ec4b81b31b13141">no_of_connected_components</a>() {</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> std::set&lt;int64_t&gt; temp; <span class="comment">// temp set to count number of connected components</span></div>
@@ -177,7 +180,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span>} <span class="comment">// namespace disjoint_union</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span>} <span class="comment">// namespace graph</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span></div>
<div class="foldopen" id="foldopen00097" data-start="{" data-end="}">
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"><a class="line" href="../../d8/d99/connected__components__with__dsu_8cpp.html#aa8dca7b867074164d5f45b0f3851269d"> 97</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>() {</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <span class="keyword">namespace </span><a class="code hl_class" href="../../dd/d1f/classdsu.html">dsu</a> = graph::disjoint_union;</div>
@@ -195,7 +198,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> std::cout &lt;&lt; dsu::no_of_connected_components() &lt;&lt; std::endl;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span>}</div>
</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> </div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span></div>
<div class="foldopen" id="foldopen00117" data-start="{" data-end="}">
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"><a class="line" href="../../d8/d99/connected__components__with__dsu_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 117</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <a class="code hl_function" href="../../d8/d99/connected__components__with__dsu_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// Execute the tests</span></div>
@@ -208,7 +211,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<div class="ttc" id="aconnected__components__with__dsu_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d8/d99/connected__components__with__dsu_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Test Implementations.</div><div class="ttdef"><b>Definition</b> <a href="#l00097">connected_components_with_dsu.cpp:97</a></div></div>
<div class="ttc" id="aconnected__components__with__dsu_8cpp_html_ac2d6698b71384a352ec4b81b31b13141"><div class="ttname"><a href="../../d8/d99/connected__components__with__dsu_8cpp.html#ac2d6698b71384a352ec4b81b31b13141">graph::disjoint_union::no_of_connected_components</a></div><div class="ttdeci">uint32_t no_of_connected_components()</div><div class="ttdoc">Find total no. of connected components.</div><div class="ttdef"><b>Definition</b> <a href="#l00085">connected_components_with_dsu.cpp:85</a></div></div>
<div class="ttc" id="aconnected__components__with__dsu_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../d8/d99/connected__components__with__dsu_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="#l00117">connected_components_with_dsu.cpp:117</a></div></div>
<div class="ttc" id="aconnected__components__with__dsu_8cpp_html_ae91ed94113c56191b75fe45f688d6e62"><div class="ttname"><a href="../../d8/d99/connected__components__with__dsu_8cpp.html#ae91ed94113c56191b75fe45f688d6e62">graph::disjoint_union::make_set</a></div><div class="ttdeci">void make_set()</div><div class="ttdoc">function the initialize every node as it's own parent</div><div class="ttdef"><b>Definition</b> <a href="#l00043">connected_components_with_dsu.cpp:43</a></div></div>
<div class="ttc" id="aconnected__components__with__dsu_8cpp_html_ae91ed94113c56191b75fe45f688d6e62"><div class="ttname"><a href="../../d8/d99/connected__components__with__dsu_8cpp.html#ae91ed94113c56191b75fe45f688d6e62">graph::disjoint_union::make_set</a></div><div class="ttdeci">void make_set()</div><div class="ttdoc">function the initialize every node as it&#39;s own parent</div><div class="ttdef"><b>Definition</b> <a href="#l00043">connected_components_with_dsu.cpp:43</a></div></div>
<div class="ttc" id="anamespacedisjoint__union_html"><div class="ttname"><a href="../../de/db4/namespacedisjoint__union.html">disjoint_union</a></div><div class="ttdoc">Functions for Disjoint union implementation.</div></div>
<div class="ttc" id="anamespacegraph_html"><div class="ttname"><a href="../../df/dce/namespacegraph.html">graph</a></div><div class="ttdoc">Graph Algorithms.</div></div>
</div><!-- fragment --></div><!-- contents -->
@@ -217,7 +220,7 @@ $(function(){initNavTree('d8/d99/connected__components__with__dsu_8cpp_source.ht
<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="../../d8/d99/connected__components__with__dsu_8cpp.html">connected_components_with_dsu.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>
<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>
</ul>
</div>
</body>