Documentation for 53a6c16730

This commit is contained in:
github-actions
2022-01-16 16:05:19 +00:00
parent 778f1be9e5
commit 2cab28c905
3620 changed files with 52045 additions and 41188 deletions

View File

@@ -3,7 +3,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.9.2"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: graph/depth_first_search_with_stack.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<tr id="projectrow">
<td id="projectalign">
<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>
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -217,16 +217,16 @@ constexpr int64_t&#160;</td><td class="memItemRight" valign="bottom"><b>INF</b>
</table>
</dd>
</dl>
<div class="fragment"><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> <span class="comment">/*</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span><span class="comment"> *</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span><span class="comment"> * Here we are considering undirected graph that&#39;s the</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span><span class="comment"> * reason we are adding v to the adjacency list representation of u</span></div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span><span class="comment"> * and also adding u to the adjacency list representation of v</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span><span class="comment"> *</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span><span class="comment"> */</span></div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> (*adj)[u - 1].push_back(v - 1);</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 64</span> {</div>
<div class="line"><span class="lineno"> 65</span> <span class="comment">/*</span></div>
<div class="line"><span class="lineno"> 66</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 67</span><span class="comment"> * Here we are considering undirected graph that&#39;s the</span></div>
<div class="line"><span class="lineno"> 68</span><span class="comment"> * reason we are adding v to the adjacency list representation of u</span></div>
<div class="line"><span class="lineno"> 69</span><span class="comment"> * and also adding u to the adjacency list representation of v</span></div>
<div class="line"><span class="lineno"> 70</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 71</span><span class="comment"> */</span></div>
<div class="line"><span class="lineno"> 72</span> (*adj)[u - 1].push_back(v - 1);</div>
<div class="line"><span class="lineno"> 73</span>}</div>
</div><!-- fragment -->
</div>
</div>
@@ -270,35 +270,35 @@ constexpr int64_t&#160;</td><td class="memItemRight" valign="bottom"><b>INF</b>
<p >push the node to the final result vector</p>
<p >exploring the neighbours of the current node</p>
<p ><a class="el" href="../../db/d8b/struct_node.html">Node</a> has been explored</p>
<div class="fragment"><div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> {<span class="comment"></span></div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span><span class="comment"> /// checked[i] stores the status of each node</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> checked(<a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>.size(), <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#afb80b42b42381658a12a57a975ecd0c7">WHITE</a>), traversed_path;</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> </div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> checked[start] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>;</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/stack.html">std::stack&lt;size_t&gt;</a> <a class="code hl_variable" href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a>;</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a5705c3926dcf5fd3f9c964467a50b81d">push</a>(start);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span><span class="comment"></span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span><span class="comment"> /// while stack is not empty we keep exploring the node on top of stack</span></div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span><span class="comment"></span> <span class="keywordflow">while</span> (!<a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.empty()) {</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="keywordtype">int</span> act = <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a21c0bb6ce7dcfe445cc12031977ea344">top</a>();</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a6cd4b95d5de00d41b2491392338384dc">pop</a>();</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> </div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <span class="keywordflow">if</span> (checked[act] == <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>) {<span class="comment"></span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span><span class="comment"> /// push the node to the final result vector</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span><span class="comment"></span> traversed_path.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(act + 1);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span><span class="comment"></span> </div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span><span class="comment"> /// exploring the neighbours of the current node</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it : <a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>[act]) {</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a5705c3926dcf5fd3f9c964467a50b81d">push</a>(it);</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="keywordflow">if</span> (checked[it] != <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>) {</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> checked[it] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>;</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> }</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> }</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> checked[act] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>; <span class="comment">/// Node has been explored</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> }</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> }</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">return</span> traversed_path;</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 87</span> {<span class="comment"></span></div>
<div class="line"><span class="lineno"> 88</span><span class="comment"> /// checked[i] stores the status of each node</span></div>
<div class="line"><span class="lineno"> 89</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> checked(<a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>.size(), <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#afb80b42b42381658a12a57a975ecd0c7">WHITE</a>), traversed_path;</div>
<div class="line"><span class="lineno"> 90</span> </div>
<div class="line"><span class="lineno"> 91</span> checked[start] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>;</div>
<div class="line"><span class="lineno"> 92</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/stack.html">std::stack&lt;size_t&gt;</a> <a class="code hl_variable" href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a>;</div>
<div class="line"><span class="lineno"> 93</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a5705c3926dcf5fd3f9c964467a50b81d">push</a>(start);</div>
<div class="line"><span class="lineno"> 94</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 95</span><span class="comment"> /// while stack is not empty we keep exploring the node on top of stack</span></div>
<div class="line"><span class="lineno"> 96</span><span class="comment"></span> <span class="keywordflow">while</span> (!<a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.empty()) {</div>
<div class="line"><span class="lineno"> 97</span> <span class="keywordtype">int</span> act = <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a21c0bb6ce7dcfe445cc12031977ea344">top</a>();</div>
<div class="line"><span class="lineno"> 98</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a6cd4b95d5de00d41b2491392338384dc">pop</a>();</div>
<div class="line"><span class="lineno"> 99</span> </div>
<div class="line"><span class="lineno"> 100</span> <span class="keywordflow">if</span> (checked[act] == <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>) {<span class="comment"></span></div>
<div class="line"><span class="lineno"> 101</span><span class="comment"> /// push the node to the final result vector</span></div>
<div class="line"><span class="lineno"> 102</span><span class="comment"></span> traversed_path.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(act + 1);</div>
<div class="line"><span class="lineno"> 103</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 104</span><span class="comment"> /// exploring the neighbours of the current node</span></div>
<div class="line"><span class="lineno"> 105</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it : <a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>[act]) {</div>
<div class="line"><span class="lineno"> 106</span> <a class="code hl_class" href="../../d1/dc2/classstack.html">stack</a>.<a class="code hl_function" href="../../d1/dc2/classstack.html#a5705c3926dcf5fd3f9c964467a50b81d">push</a>(it);</div>
<div class="line"><span class="lineno"> 107</span> <span class="keywordflow">if</span> (checked[it] != <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>) {</div>
<div class="line"><span class="lineno"> 108</span> checked[it] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a>;</div>
<div class="line"><span class="lineno"> 109</span> }</div>
<div class="line"><span class="lineno"> 110</span> }</div>
<div class="line"><span class="lineno"> 111</span> checked[act] = <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>; <span class="comment">/// Node has been explored</span></div>
<div class="line"><span class="lineno"> 112</span> }</div>
<div class="line"><span class="lineno"> 113</span> }</div>
<div class="line"><span class="lineno"> 114</span> <span class="keywordflow">return</span> traversed_path;</div>
<div class="line"><span class="lineno"> 115</span>}</div>
<div class="ttc" id="aclassstack_html"><div class="ttname"><a href="../../d1/dc2/classstack.html">stack</a></div><div class="ttdef"><b>Definition:</b> stack.h:26</div></div>
<div class="ttc" id="aclassstack_html_a21c0bb6ce7dcfe445cc12031977ea344"><div class="ttname"><a href="../../d1/dc2/classstack.html#a21c0bb6ce7dcfe445cc12031977ea344">stack::top</a></div><div class="ttdeci">Type top()</div><div class="ttdef"><b>Definition:</b> stack.h:93</div></div>
<div class="ttc" id="aclassstack_html_a5705c3926dcf5fd3f9c964467a50b81d"><div class="ttname"><a href="../../d1/dc2/classstack.html#a5705c3926dcf5fd3f9c964467a50b81d">stack::push</a></div><div class="ttdeci">void push(Type item)</div><div class="ttdef"><b>Definition:</b> stack.h:83</div></div>
@@ -342,41 +342,41 @@ Here is the call graph for this function:</div>
<p >taking input for the edges</p>
<p >taking input for the starting position</p>
<p >Printing the order of traversal</p>
<div class="fragment"><div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> {</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// execute the tests</span></div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> </div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <span class="keywordtype">size_t</span> vertices = 0, edges = 0, start_pos = 1;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> traversal;</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> </div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</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;Enter the Vertices : &quot;</span>;</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; vertices;</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</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;Enter the Edges : &quot;</span>;</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; edges;</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span><span class="comment"></span> </div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span><span class="comment"> /// creating a graph</span></div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; adj(vertices, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span><span class="comment"></span> </div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span><span class="comment"> /// taking input for the edges</span></div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span><span class="comment"></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;Enter the vertices which have edges between them : &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> <span class="keywordflow">while</span> (edges--) {</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> <span class="keywordtype">size_t</span> u = 0, v = 0;</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</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="l00192" name="l00192"></a><span class="lineno"> 192</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;adj, u, v);</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> }</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span><span class="comment"></span> </div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span><span class="comment"> /// taking input for the starting position</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span><span class="comment"></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;Enter the starting vertex [1,n]: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; start_pos;</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> start_pos -= 1;</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> traversal = <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a>(adj, start_pos);</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span><span class="comment"></span> </div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span><span class="comment"> /// Printing the order of traversal</span></div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> x : traversal) {</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; x &lt;&lt; <span class="charliteral">&#39; &#39;</span>;</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> }</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> </div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 173</span> {</div>
<div class="line"><span class="lineno"> 174</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// execute the tests</span></div>
<div class="line"><span class="lineno"> 175</span> </div>
<div class="line"><span class="lineno"> 176</span> <span class="keywordtype">size_t</span> vertices = 0, edges = 0, start_pos = 1;</div>
<div class="line"><span class="lineno"> 177</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> traversal;</div>
<div class="line"><span class="lineno"> 178</span> </div>
<div class="line"><span class="lineno"> 179</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;Enter the Vertices : &quot;</span>;</div>
<div class="line"><span class="lineno"> 180</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; vertices;</div>
<div class="line"><span class="lineno"> 181</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;Enter the Edges : &quot;</span>;</div>
<div class="line"><span class="lineno"> 182</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; edges;</div>
<div class="line"><span class="lineno"> 183</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 184</span><span class="comment"> /// creating a graph</span></div>
<div class="line"><span class="lineno"> 185</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; adj(vertices, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><span class="lineno"> 186</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 187</span><span class="comment"> /// taking input for the edges</span></div>
<div class="line"><span class="lineno"> 188</span><span class="comment"></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;Enter the vertices which have edges between them : &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 189</span> <span class="keywordflow">while</span> (edges--) {</div>
<div class="line"><span class="lineno"> 190</span> <span class="keywordtype">size_t</span> u = 0, v = 0;</div>
<div class="line"><span class="lineno"> 191</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"><span class="lineno"> 192</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;adj, u, v);</div>
<div class="line"><span class="lineno"> 193</span> }</div>
<div class="line"><span class="lineno"> 194</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 195</span><span class="comment"> /// taking input for the starting position</span></div>
<div class="line"><span class="lineno"> 196</span><span class="comment"></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;Enter the starting vertex [1,n]: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 197</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; start_pos;</div>
<div class="line"><span class="lineno"> 198</span> start_pos -= 1;</div>
<div class="line"><span class="lineno"> 199</span> traversal = <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a>(adj, start_pos);</div>
<div class="line"><span class="lineno"> 200</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 201</span><span class="comment"> /// Printing the order of traversal</span></div>
<div class="line"><span class="lineno"> 202</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> x : traversal) {</div>
<div class="line"><span class="lineno"> 203</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; x &lt;&lt; <span class="charliteral">&#39; &#39;</span>;</div>
<div class="line"><span class="lineno"> 204</span> }</div>
<div class="line"><span class="lineno"> 205</span> </div>
<div class="line"><span class="lineno"> 206</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 207</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="adepth__first__search__with__stack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdef"><b>Definition:</b> depth_first_search_with_stack.cpp:123</div></div>
@@ -421,51 +421,51 @@ Here is the call graph for this function:</div>
<p >for the above sample data, this is the expected output</p>
<p >Test 3</p>
<p >for the above sample data, this is the expected output</p>
<div class="fragment"><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="keywordtype">size_t</span> start_pos;</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span><span class="comment"></span> </div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span><span class="comment"> /// Test 1</span></div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span><span class="comment"></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;Case 1: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> start_pos = 1;</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g1(3, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> </div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 1, 2);</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 2, 3);</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 3, 1);</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> </div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected1 {1, 2, 3}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> assert(graph::depth_first_search::dfs(g1, start_pos - 1) == expected1);</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span><span class="comment"></span> </div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span><span class="comment"> /// Test 2</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span><span class="comment"></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;Case 2: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> start_pos = 1;</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g2(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> </div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 1, 2);</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 1, 3);</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 2, 4);</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 4, 1);</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> </div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected2 {1, 3, 2, 4}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> assert(graph::depth_first_search::dfs(g2, start_pos - 1) == expected2);</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span><span class="comment"></span> </div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span><span class="comment"> /// Test 3</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span><span class="comment"></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;Case 3: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> start_pos = 2;</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g3(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> </div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 1, 2);</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 1, 3);</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 2, 4);</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 4, 1);</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected3 {2, 4, 1, 3}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> assert(graph::depth_first_search::dfs(g3, start_pos - 1) == expected3);</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> </div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 123</span> {</div>
<div class="line"><span class="lineno"> 124</span> <span class="keywordtype">size_t</span> start_pos;</div>
<div class="line"><span class="lineno"> 125</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 126</span><span class="comment"> /// Test 1</span></div>
<div class="line"><span class="lineno"> 127</span><span class="comment"></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;Case 1: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 128</span> start_pos = 1;</div>
<div class="line"><span class="lineno"> 129</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g1(3, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><span class="lineno"> 130</span> </div>
<div class="line"><span class="lineno"> 131</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 1, 2);</div>
<div class="line"><span class="lineno"> 132</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 2, 3);</div>
<div class="line"><span class="lineno"> 133</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g1, 3, 1);</div>
<div class="line"><span class="lineno"> 134</span> </div>
<div class="line"><span class="lineno"> 135</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected1 {1, 2, 3}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><span class="lineno"> 136</span> assert(graph::depth_first_search::dfs(g1, start_pos - 1) == expected1);</div>
<div class="line"><span class="lineno"> 137</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 138</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 139</span><span class="comment"> /// Test 2</span></div>
<div class="line"><span class="lineno"> 140</span><span class="comment"></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;Case 2: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 141</span> start_pos = 1;</div>
<div class="line"><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g2(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><span class="lineno"> 143</span> </div>
<div class="line"><span class="lineno"> 144</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 1, 2);</div>
<div class="line"><span class="lineno"> 145</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 1, 3);</div>
<div class="line"><span class="lineno"> 146</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 2, 4);</div>
<div class="line"><span class="lineno"> 147</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g2, 4, 1);</div>
<div class="line"><span class="lineno"> 148</span> </div>
<div class="line"><span class="lineno"> 149</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected2 {1, 3, 2, 4}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><span class="lineno"> 150</span> assert(graph::depth_first_search::dfs(g2, start_pos - 1) == expected2);</div>
<div class="line"><span class="lineno"> 151</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 152</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 153</span><span class="comment"> /// Test 3</span></div>
<div class="line"><span class="lineno"> 154</span><span class="comment"></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;Case 3: &quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 155</span> start_pos = 2;</div>
<div class="line"><span class="lineno"> 156</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;size_t&gt;</a> &gt; g3(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a>());</div>
<div class="line"><span class="lineno"> 157</span> </div>
<div class="line"><span class="lineno"> 158</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 1, 2);</div>
<div class="line"><span class="lineno"> 159</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 1, 3);</div>
<div class="line"><span class="lineno"> 160</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 2, 4);</div>
<div class="line"><span class="lineno"> 161</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&amp;g3, 4, 1);</div>
<div class="line"><span class="lineno"> 162</span> </div>
<div class="line"><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;size_t&gt;</a> expected3 {2, 4, 1, 3}; <span class="comment">/// for the above sample data, this is the expected output</span></div>
<div class="line"><span class="lineno"> 164</span> assert(graph::depth_first_search::dfs(g3, start_pos - 1) == expected3);</div>
<div class="line"><span class="lineno"> 165</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;Passed&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 166</span> </div>
<div class="line"><span class="lineno"> 167</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -505,7 +505,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="../../da/d4b/depth__first__search__with__stack_8cpp.html">depth_first_search_with_stack.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.2 </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.3 </li>
</ul>
</div>
</body>