mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-11 19:17:21 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: graph/depth_first_search_with_stack.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: graph/depth_first_search_with_stack.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -124,7 +141,9 @@ Include dependency graph for depth_first_search_with_stack.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/dfe/depth__first__search__with__stack_8cpp__incl.svg" width="407" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
</div>
|
||||
<p><a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
Namespaces</h2></td></tr>
|
||||
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/dce/namespacegraph.html">graph</a></td></tr>
|
||||
@@ -136,10 +155,10 @@ Namespaces</h2></td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:aadebe9c855821d6515ca5b171222ef7b" id="r_aadebe9c855821d6515ca5b171222ef7b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > > *adj, size_t u, size_t v)</td></tr>
|
||||
<tr class="memitem:aadebe9c855821d6515ca5b171222ef7b" id="r_aadebe9c855821d6515ca5b171222ef7b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a> (std::vector< std::vector< size_t > > *adj, size_t u, size_t v)</td></tr>
|
||||
<tr class="memdesc:aadebe9c855821d6515ca5b171222ef7b"><td class="mdescLeft"> </td><td class="mdescRight">Adds and edge between two vertices of graph say u and v in this case. <br /></td></tr>
|
||||
<tr class="separator:aadebe9c855821d6515ca5b171222ef7b"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a5738da9f508f6a9e87f123c9fb6f2ea9" id="r_a5738da9f508f6a9e87f123c9fb6f2ea9"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > </td><td class="memItemRight" valign="bottom"><a class="el" href="#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > > &graph, size_t start)</td></tr>
|
||||
<tr class="memitem:a5738da9f508f6a9e87f123c9fb6f2ea9" id="r_a5738da9f508f6a9e87f123c9fb6f2ea9"><td class="memItemLeft" align="right" valign="top">std::vector< size_t > </td><td class="memItemRight" valign="bottom"><a class="el" href="#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a> (const std::vector< std::vector< size_t > > &graph, size_t start)</td></tr>
|
||||
<tr class="memdesc:a5738da9f508f6a9e87f123c9fb6f2ea9"><td class="mdescLeft"> </td><td class="mdescRight">Explores the given vertex, exploring a vertex means traversing over all the vertices which are connected to the vertex that is currently being explored and push it onto the stack. <br /></td></tr>
|
||||
<tr class="separator:a5738da9f508f6a9e87f123c9fb6f2ea9"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a483bb8ccf42aaf7375a83e91490eda1e" id="r_a483bb8ccf42aaf7375a83e91490eda1e"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a> ()</td></tr>
|
||||
@@ -152,17 +171,14 @@ Functions</h2></td></tr>
|
||||
Variables</h2></td></tr>
|
||||
<tr class="memitem:afb80b42b42381658a12a57a975ecd0c7" id="r_afb80b42b42381658a12a57a975ecd0c7"><td class="memItemLeft" align="right" valign="top">constexpr int </td><td class="memItemRight" valign="bottom"><a class="el" href="#afb80b42b42381658a12a57a975ecd0c7">WHITE</a> = 0</td></tr>
|
||||
<tr class="separator:afb80b42b42381658a12a57a975ecd0c7"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a43e30173f12330e85cce6239a277527e" id="r_a43e30173f12330e85cce6239a277527e"><td class="memItemLeft" align="right" valign="top"><a id="a43e30173f12330e85cce6239a277527e" name="a43e30173f12330e85cce6239a277527e"></a>
|
||||
constexpr int </td><td class="memItemRight" valign="bottom"><b>GREY</b> = 1</td></tr>
|
||||
<tr class="memdesc:a43e30173f12330e85cce6239a277527e"><td class="mdescLeft"> </td><td class="mdescRight">indicates the node hasn't been explored <br /></td></tr>
|
||||
<tr class="memitem:a43e30173f12330e85cce6239a277527e" id="r_a43e30173f12330e85cce6239a277527e"><td class="memItemLeft" align="right" valign="top">constexpr int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a43e30173f12330e85cce6239a277527e">GREY</a> = 1</td></tr>
|
||||
<tr class="memdesc:a43e30173f12330e85cce6239a277527e"><td class="mdescLeft"> </td><td class="mdescRight">indicates the node hasn't been explored <br /></td></tr>
|
||||
<tr class="separator:a43e30173f12330e85cce6239a277527e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a7f1cd94cf4da32933e8551cb3577e18b" id="r_a7f1cd94cf4da32933e8551cb3577e18b"><td class="memItemLeft" align="right" valign="top"><a id="a7f1cd94cf4da32933e8551cb3577e18b" name="a7f1cd94cf4da32933e8551cb3577e18b"></a>
|
||||
constexpr int </td><td class="memItemRight" valign="bottom"><b>BLACK</b> = 2</td></tr>
|
||||
<tr class="memdesc:a7f1cd94cf4da32933e8551cb3577e18b"><td class="mdescLeft"> </td><td class="mdescRight">indicates node is in stack waiting to be explored <br /></td></tr>
|
||||
<tr class="memitem:a7f1cd94cf4da32933e8551cb3577e18b" id="r_a7f1cd94cf4da32933e8551cb3577e18b"><td class="memItemLeft" align="right" valign="top">constexpr int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a> = 2</td></tr>
|
||||
<tr class="memdesc:a7f1cd94cf4da32933e8551cb3577e18b"><td class="mdescLeft"> </td><td class="mdescRight">indicates node is in stack waiting to be explored <br /></td></tr>
|
||||
<tr class="separator:a7f1cd94cf4da32933e8551cb3577e18b"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a330a2b0a904f01802ada1f8f3b28e76c" id="r_a330a2b0a904f01802ada1f8f3b28e76c"><td class="memItemLeft" align="right" valign="top"><a id="a330a2b0a904f01802ada1f8f3b28e76c" name="a330a2b0a904f01802ada1f8f3b28e76c"></a>
|
||||
constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b> = <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/numeric_limits.html">std::numeric_limits</a><int16_t>::max()</td></tr>
|
||||
<tr class="memdesc:a330a2b0a904f01802ada1f8f3b28e76c"><td class="mdescLeft"> </td><td class="mdescRight">indicates node has already been explored <br /></td></tr>
|
||||
<tr class="memitem:a330a2b0a904f01802ada1f8f3b28e76c" id="r_a330a2b0a904f01802ada1f8f3b28e76c"><td class="memItemLeft" align="right" valign="top">constexpr int64_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#a330a2b0a904f01802ada1f8f3b28e76c">INF</a> = std::numeric_limits<int16_t>::max()</td></tr>
|
||||
<tr class="memdesc:a330a2b0a904f01802ada1f8f3b28e76c"><td class="mdescLeft"> </td><td class="mdescRight">indicates node has already been explored <br /></td></tr>
|
||||
<tr class="separator:a330a2b0a904f01802ada1f8f3b28e76c"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
@@ -188,6 +204,8 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
<li>Push all its neighbours which are not coloured BLACK.</li>
|
||||
<li>Repeat steps 4 and 5 until the stack is empty. </li>
|
||||
</ol>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="aadebe9c855821d6515ca5b171222ef7b" name="aadebe9c855821d6515ca5b171222ef7b"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aadebe9c855821d6515ca5b171222ef7b">◆ </a></span>addEdge()</h2>
|
||||
@@ -198,7 +216,7 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
<tr>
|
||||
<td class="memname">void graph::depth_first_search::addEdge </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > > *</td> <td class="paramname"><span class="paramname"><em>adj</em></span>, </td>
|
||||
<td class="paramtype">std::vector< std::vector< size_t > > *</td> <td class="paramname"><span class="paramname"><em>adj</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -222,6 +240,8 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00064">64</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
<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>
|
||||
@@ -242,9 +262,9 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > graph::depth_first_search::dfs </td>
|
||||
<td class="memname">std::vector< size_t > graph::depth_first_search::dfs </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< size_t > > &</td> <td class="paramname"><span class="paramname"><em>graph</em></span>, </td>
|
||||
<td class="paramtype">const std::vector< std::vector< size_t > > &</td> <td class="paramname"><span class="paramname"><em>graph</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -268,53 +288,43 @@ constexpr int64_t </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"><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<size_t></a> checked(<a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>.size(), <a class="code hl_variable" href="#afb80b42b42381658a12a57a975ecd0c7">WHITE</a>), traversed_path;</div>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00087">87</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 87</span> {</div>
|
||||
<div class="line"><span class="lineno"> 89</span> std::vector<size_t> checked(<a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>.size(), <a class="code hl_variable" href="#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="#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<size_t></a> <a class="code hl_variable" href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a>;</div>
|
||||
<div class="line"><span class="lineno"> 92</span> std::stack<size_t> <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#a90df277532c23519aa7ac3c08ed90a1d">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"> 94</span> </div>
|
||||
<div class="line"><span class="lineno"> 96</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#ae09630c4384903d187801921b2ddc709">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#a3647fb4418890f19e0dc414b8092b8b0">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="#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"> 100</span> <span class="keywordflow">if</span> (checked[act] == <a class="code hl_variable" href="#a43e30173f12330e85cce6239a277527e">GREY</a>) {</div>
|
||||
<div class="line"><span class="lineno"> 102</span> traversed_path.push_back(act + 1);</div>
|
||||
<div class="line"><span class="lineno"> 103</span> </div>
|
||||
<div class="line"><span class="lineno"> 105</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#a90df277532c23519aa7ac3c08ed90a1d">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="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>) {</div>
|
||||
<div class="line"><span class="lineno"> 108</span> checked[it] = <a class="code hl_variable" href="#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="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>; <span class="comment">/// Node has been explored</span></div>
|
||||
<div class="line"><span class="lineno"> 111</span> checked[act] = <a class="code hl_variable" href="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a>; </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="ttdoc">for std::invalid_argument</div><div class="ttdef"><b>Definition</b> stack.hpp:19</div></div>
|
||||
<div class="ttc" id="aclassstack_html_a3647fb4418890f19e0dc414b8092b8b0"><div class="ttname"><a href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0">stack::pop</a></div><div class="ttdeci">void pop()</div><div class="ttdef"><b>Definition</b> stack.hpp:62</div></div>
|
||||
<div class="ttc" id="aclassstack_html_a90df277532c23519aa7ac3c08ed90a1d"><div class="ttname"><a href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">stack::push</a></div><div class="ttdeci">void push(const value_type &item)</div><div class="ttdef"><b>Definition</b> stack.hpp:47</div></div>
|
||||
<div class="ttc" id="aclassstack_html_ae09630c4384903d187801921b2ddc709"><div class="ttname"><a href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">stack::top</a></div><div class="ttdeci">value_type top() const</div><div class="ttdef"><b>Definition</b> stack.hpp:56</div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a43e30173f12330e85cce6239a277527e"><div class="ttname"><a href="#a43e30173f12330e85cce6239a277527e">GREY</a></div><div class="ttdeci">constexpr int GREY</div><div class="ttdoc">indicates the node hasn't been explored</div><div class="ttdef"><b>Definition</b> depth_first_search_with_stack.cpp:39</div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a7f1cd94cf4da32933e8551cb3577e18b"><div class="ttname"><a href="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a></div><div class="ttdeci">constexpr int BLACK</div><div class="ttdoc">indicates node is in stack waiting to be explored</div><div class="ttdef"><b>Definition</b> depth_first_search_with_stack.cpp:40</div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_afb80b42b42381658a12a57a975ecd0c7"><div class="ttname"><a href="#afb80b42b42381658a12a57a975ecd0c7">WHITE</a></div><div class="ttdeci">constexpr int WHITE</div><div class="ttdef"><b>Definition</b> depth_first_search_with_stack.cpp:38</div></div>
|
||||
<div class="ttc" id="aclassstack_html"><div class="ttname"><a href="../../d1/dc2/classstack.html">stack</a></div><div class="ttdoc">for std::invalid_argument</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00019">stack.hpp:19</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_a3647fb4418890f19e0dc414b8092b8b0"><div class="ttname"><a href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0">stack::pop</a></div><div class="ttdeci">void pop()</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00062">stack.hpp:62</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_a90df277532c23519aa7ac3c08ed90a1d"><div class="ttname"><a href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">stack::push</a></div><div class="ttdeci">void push(const value_type &item)</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00047">stack.hpp:47</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_ae09630c4384903d187801921b2ddc709"><div class="ttname"><a href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">stack::top</a></div><div class="ttdeci">value_type top() const</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00056">stack.hpp:56</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a43e30173f12330e85cce6239a277527e"><div class="ttname"><a href="#a43e30173f12330e85cce6239a277527e">GREY</a></div><div class="ttdeci">constexpr int GREY</div><div class="ttdoc">indicates the node hasn't been explored</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00039">depth_first_search_with_stack.cpp:39</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a7f1cd94cf4da32933e8551cb3577e18b"><div class="ttname"><a href="#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a></div><div class="ttdeci">constexpr int BLACK</div><div class="ttdoc">indicates node is in stack waiting to be explored</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00040">depth_first_search_with_stack.cpp:40</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_afb80b42b42381658a12a57a975ecd0c7"><div class="ttname"><a href="#afb80b42b42381658a12a57a975ecd0c7">WHITE</a></div><div class="ttdeci">constexpr int WHITE</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00038">depth_first_search_with_stack.cpp:38</a></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 class="ttc" id="aparanthesis__matching_8cpp_html_aa37d24a036d239b3b528f13b9de880c7"><div class="ttname"><a href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a></div><div class="ttdeci">char stack[MAX]</div><div class="ttdef"><b>Definition</b> paranthesis_matching.cpp:20</div></div>
|
||||
<div class="ttc" id="apush_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a></div><div class="ttdeci">T push_back(T... args)</div></div>
|
||||
<div class="ttc" id="astack_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/stack.html">std::stack</a></div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d4b/depth__first__search__with__stack_8cpp_a5738da9f508f6a9e87f123c9fb6f2ea9_cgraph.svg" width="510" height="184"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aparanthesis__matching_8cpp_html_aa37d24a036d239b3b528f13b9de880c7"><div class="ttname"><a href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a></div><div class="ttdeci">char stack[MAX]</div><div class="ttdef"><b>Definition</b> <a href="../../dc/dc5/paranthesis__matching_8cpp_source.html#l00020">paranthesis_matching.cpp:20</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
@@ -338,53 +348,43 @@ 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>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00173">173</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
<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="#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<size_t></a> traversal;</div>
|
||||
<div class="line"><span class="lineno"> 177</span> std::vector<size_t> 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> << <span class="stringliteral">"Enter the Vertices : "</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> >> 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> << <span class="stringliteral">"Enter the Edges : "</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> >> 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<std::vector<size_t></a> > adj(vertices, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<size_t></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> << <span class="stringliteral">"Enter the vertices which have edges between them : "</span> << <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"> 179</span> std::cout << <span class="stringliteral">"Enter the Vertices : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 180</span> std::cin >> vertices;</div>
|
||||
<div class="line"><span class="lineno"> 181</span> std::cout << <span class="stringliteral">"Enter the Edges : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 182</span> std::cin >> edges;</div>
|
||||
<div class="line"><span class="lineno"> 183</span> </div>
|
||||
<div class="line"><span class="lineno"> 185</span> std::vector<std::vector<size_t> > adj(vertices, std::vector<size_t>());</div>
|
||||
<div class="line"><span class="lineno"> 186</span> </div>
|
||||
<div class="line"><span class="lineno"> 188</span> std::cout << <span class="stringliteral">"Enter the vertices which have edges between them : "</span> << std::endl;</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> >> u >> v;</div>
|
||||
<div class="line"><span class="lineno"> 191</span> std::cin >> u >> v;</div>
|
||||
<div class="line"><span class="lineno"> 192</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&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> << <span class="stringliteral">"Enter the starting vertex [1,n]: "</span> << <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> >> start_pos;</div>
|
||||
<div class="line"><span class="lineno"> 194</span> </div>
|
||||
<div class="line"><span class="lineno"> 196</span> std::cout << <span class="stringliteral">"Enter the starting vertex [1,n]: "</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 197</span> std::cin >> 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="#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> << x << <span class="charliteral">' '</span>;</div>
|
||||
<div class="line"><span class="lineno"> 200</span> </div>
|
||||
<div class="line"><span class="lineno"> 202</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> x : traversal) {</div>
|
||||
<div class="line"><span class="lineno"> 203</span> std::cout << x << <span class="charliteral">' '</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="#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>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a5738da9f508f6a9e87f123c9fb6f2ea9"><div class="ttname"><a href="#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a></div><div class="ttdeci">std::vector< size_t > dfs(const std::vector< std::vector< size_t > > &graph, size_t start)</div><div class="ttdoc">Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec...</div><div class="ttdef"><b>Definition</b> depth_first_search_with_stack.cpp:87</div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_aadebe9c855821d6515ca5b171222ef7b"><div class="ttname"><a href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a></div><div class="ttdeci">void addEdge(std::vector< std::vector< size_t > > *adj, size_t u, size_t v)</div><div class="ttdoc">Adds and edge between two vertices of graph say u and v in this case.</div><div class="ttdef"><b>Definition</b> depth_first_search_with_stack.cpp:64</div></div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d4b/depth__first__search__with__stack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="278" height="62"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00123">depth_first_search_with_stack.cpp:123</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a5738da9f508f6a9e87f123c9fb6f2ea9"><div class="ttname"><a href="#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a></div><div class="ttdeci">std::vector< size_t > dfs(const std::vector< std::vector< size_t > > &graph, size_t start)</div><div class="ttdoc">Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec...</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00087">depth_first_search_with_stack.cpp:87</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_aadebe9c855821d6515ca5b171222ef7b"><div class="ttname"><a href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a></div><div class="ttdeci">void addEdge(std::vector< std::vector< size_t > > *adj, size_t u, size_t v)</div><div class="ttdoc">Adds and edge between two vertices of graph say u and v in this case.</div><div class="ttdef"><b>Definition</b> <a href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00064">depth_first_search_with_stack.cpp:64</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a483bb8ccf42aaf7375a83e91490eda1e" name="a483bb8ccf42aaf7375a83e91490eda1e"></a>
|
||||
@@ -416,60 +416,132 @@ 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>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00123">123</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
<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> << <span class="stringliteral">"Case 1: "</span> << <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"> 125</span> </div>
|
||||
<div class="line"><span class="lineno"> 127</span> std::cout << <span class="stringliteral">"Case 1: "</span> << std::endl;</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<std::vector<size_t></a> > g1(3, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<size_t></a>());</div>
|
||||
<div class="line"><span class="lineno"> 129</span> std::vector<std::vector<size_t> > g1(3, std::vector<size_t>());</div>
|
||||
<div class="line"><span class="lineno"> 130</span> </div>
|
||||
<div class="line"><span class="lineno"> 131</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g1, 1, 2);</div>
|
||||
<div class="line"><span class="lineno"> 132</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g1, 2, 3);</div>
|
||||
<div class="line"><span class="lineno"> 133</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&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<size_t></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"> 135</span> std::vector<size_t> expected1 {1, 2, 3}; </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> << <span class="stringliteral">"Passed"</span> << <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> << <span class="stringliteral">"Case 2: "</span> << <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"> 137</span> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 138</span> </div>
|
||||
<div class="line"><span class="lineno"> 140</span> std::cout << <span class="stringliteral">"Case 2: "</span> << std::endl;</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<std::vector<size_t></a> > g2(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<size_t></a>());</div>
|
||||
<div class="line"><span class="lineno"> 142</span> std::vector<std::vector<size_t> > g2(4, std::vector<size_t>());</div>
|
||||
<div class="line"><span class="lineno"> 143</span> </div>
|
||||
<div class="line"><span class="lineno"> 144</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g2, 1, 2);</div>
|
||||
<div class="line"><span class="lineno"> 145</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g2, 1, 3);</div>
|
||||
<div class="line"><span class="lineno"> 146</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g2, 2, 4);</div>
|
||||
<div class="line"><span class="lineno"> 147</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&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<size_t></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"> 149</span> std::vector<size_t> expected2 {1, 3, 2, 4}; </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> << <span class="stringliteral">"Passed"</span> << <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> << <span class="stringliteral">"Case 3: "</span> << <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"> 151</span> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 152</span> </div>
|
||||
<div class="line"><span class="lineno"> 154</span> std::cout << <span class="stringliteral">"Case 3: "</span> << std::endl;</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<std::vector<size_t></a> > g3(4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<size_t></a>());</div>
|
||||
<div class="line"><span class="lineno"> 156</span> std::vector<std::vector<size_t> > g3(4, std::vector<size_t>());</div>
|
||||
<div class="line"><span class="lineno"> 157</span> </div>
|
||||
<div class="line"><span class="lineno"> 158</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g3, 1, 2);</div>
|
||||
<div class="line"><span class="lineno"> 159</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g3, 1, 3);</div>
|
||||
<div class="line"><span class="lineno"> 160</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&g3, 2, 4);</div>
|
||||
<div class="line"><span class="lineno"> 161</span> <a class="code hl_function" href="#aadebe9c855821d6515ca5b171222ef7b">graph::depth_first_search::addEdge</a>(&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<size_t></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"> 163</span> std::vector<size_t> expected3 {2, 4, 1, 3}; </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> << <span class="stringliteral">"Passed"</span> << <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"> 165</span> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</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">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d4b/depth__first__search__with__stack_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg" width="180" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="groupheader">Variable Documentation</h2>
|
||||
<a id="a7f1cd94cf4da32933e8551cb3577e18b" name="a7f1cd94cf4da32933e8551cb3577e18b"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a7f1cd94cf4da32933e8551cb3577e18b">◆ </a></span>BLACK</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="mlabels">
|
||||
<tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">int BLACK = 2</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>indicates node is in stack waiting to be explored </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00040">40</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a43e30173f12330e85cce6239a277527e" name="a43e30173f12330e85cce6239a277527e"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a43e30173f12330e85cce6239a277527e">◆ </a></span>GREY</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="mlabels">
|
||||
<tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">int GREY = 1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>indicates the node hasn't been explored </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00039">39</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a330a2b0a904f01802ada1f8f3b28e76c" name="a330a2b0a904f01802ada1f8f3b28e76c"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a330a2b0a904f01802ada1f8f3b28e76c">◆ </a></span>INF</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="mlabels">
|
||||
<tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">int64_t INF = std::numeric_limits<int16_t>::max()</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">constexpr</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>indicates node has already been explored </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00041">41</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="afb80b42b42381658a12a57a975ecd0c7" name="afb80b42b42381658a12a57a975ecd0c7"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#afb80b42b42381658a12a57a975ecd0c7">◆ </a></span>WHITE</h2>
|
||||
|
||||
@@ -489,7 +561,9 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>for IO operations header for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/stack.html">std::stack</a> header for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a> header for preprocessor macro assert() header for limits of integral types </p>
|
||||
<p>for IO operations header for std::stack header for std::vector header for preprocessor macro assert() header for limits of integral types </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html#l00038">38</a> of file <a class="el" href="../../da/d4b/depth__first__search__with__stack_8cpp_source.html">depth_first_search_with_stack.cpp</a>.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<map id="tests" name="tests">
|
||||
<area shape="rect" id="Node000001" title=" " alt="" coords="5,5,56,31"/>
|
||||
<area shape="rect" id="Node000002" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="104,5,175,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="56,16,88,16,88,21,56,21"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
53c50817a16c14e9053dbcf470acfa9d
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: tests Pages: 1 -->
|
||||
<svg width="135pt" height="27pt"
|
||||
viewBox="0.00 0.00 135.25 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>tests</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="37.75,-19.25 0,-19.25 0,0 37.75,0 37.75,-19.25"/>
|
||||
<text text-anchor="middle" x="18.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="127.25,-19.25 73.75,-19.25 73.75,0 127.25,0 127.25,-19.25"/>
|
||||
<text text-anchor="middle" x="100.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.94,-9.62C45.14,-9.62 53.69,-9.62 62.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.84,-13.13 71.83,-9.63 61.83,-6.13 61.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: tests Pages: 1 -->
|
||||
<svg width="135pt" height="27pt"
|
||||
viewBox="0.00 0.00 135.25 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>tests</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="37.75,-19.25 0,-19.25 0,0 37.75,0 37.75,-19.25"/>
|
||||
<text text-anchor="middle" x="18.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="127.25,-19.25 73.75,-19.25 73.75,0 127.25,0 127.25,-19.25"/>
|
||||
<text text-anchor="middle" x="100.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.94,-9.62C45.14,-9.62 53.69,-9.62 62.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.84,-13.13 71.83,-9.63 61.83,-6.13 61.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,14 +0,0 @@
|
||||
<map id="graph::depth_first_search::dfs" name="graph::depth_first_search::dfs">
|
||||
<area shape="rect" id="Node000001" title="Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec..." alt="" coords="5,72,128,113"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000001" title=" " alt="" coords="31,72,29,63,35,54,48,48,67,46,87,48,99,55,97,59,85,53,66,51,49,53,38,58,34,64,36,71"/>
|
||||
<area shape="rect" id="Node000002" href="$d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0" title=" " alt="" coords="212,5,294,31"/>
|
||||
<area shape="poly" id="edge2_Node000001_Node000002" title=" " alt="" coords="108,70,175,40,196,32,198,37,177,45,110,74"/>
|
||||
<area shape="rect" id="Node000003" href="$d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d" title=" " alt="" coords="208,55,298,80"/>
|
||||
<area shape="poly" id="edge3_Node000001_Node000003" title=" " alt="" coords="128,82,192,73,193,78,128,87"/>
|
||||
<area shape="rect" id="Node000005" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back.html#" title=" " alt="" coords="176,104,330,130"/>
|
||||
<area shape="poly" id="edge5_Node000001_Node000005" title=" " alt="" coords="128,98,161,102,160,108,128,103"/>
|
||||
<area shape="rect" id="Node000006" href="$d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709" title=" " alt="" coords="213,153,292,179"/>
|
||||
<area shape="poly" id="edge6_Node000001_Node000006" title=" " alt="" coords="111,111,177,140,199,148,197,153,175,145,109,116"/>
|
||||
<area shape="rect" id="Node000004" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/memory/shared_ptr/make_shared.html#" title=" " alt="" coords="378,55,503,80"/>
|
||||
<area shape="poly" id="edge4_Node000003_Node000004" title=" " alt="" coords="298,65,363,65,363,70,298,70"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
d93bebf7695f3d516651f57455a0725f
|
||||
@@ -1,147 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: graph::depth_first_search::dfs Pages: 1 -->
|
||||
<svg width="382pt" height="138pt"
|
||||
viewBox="0.00 0.00 381.50 138.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 134.25)">
|
||||
<title>graph::depth_first_search::dfs</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec...">
|
||||
<polygon fill="#999999" stroke="#666666" points="91.75,-79.88 0,-79.88 0,-49.38 91.75,-49.38 91.75,-79.88"/>
|
||||
<text text-anchor="start" x="8" y="-66.38" font-family="Helvetica,sans-Serif" font-size="10.00">graph::depth_first</text>
|
||||
<text text-anchor="middle" x="45.88" y="-55.12" font-family="Helvetica,sans-Serif" font-size="10.00">_search::dfs</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge1_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge1_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M21.11,-80.36C16.06,-89.43 24.31,-97.88 45.88,-97.88 57.67,-97.88 65.48,-95.35 69.31,-91.58"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="72.76,-92.21 70.46,-81.86 65.81,-91.38 72.76,-92.21"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="216.5,-130.25 154.75,-130.25 154.75,-111 216.5,-111 216.5,-130.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-116.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::pop</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge2_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge2_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M77.56,-80.22C92.5,-87.51 110.85,-96.01 127.75,-102.62 132.79,-104.6 138.14,-106.51 143.47,-108.31"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="142.23,-111.59 152.82,-111.36 144.4,-104.94 142.23,-111.59"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="219.12,-93.25 152.12,-93.25 152.12,-74 219.12,-74 219.12,-93.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-79.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::push</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge3_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge3_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M91.98,-70.85C107.49,-72.99 124.82,-75.38 140.27,-77.51"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="139.77,-80.97 150.15,-78.87 140.73,-74.04 139.77,-80.97"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node5 -->
|
||||
<g id="Node000005" class="node">
|
||||
<title>Node5</title>
|
||||
<g id="a_Node000005"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="243.5,-56.25 127.75,-56.25 127.75,-37 243.5,-37 243.5,-56.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node5 -->
|
||||
<g id="edge5_Node000001_Node000005" class="edge">
|
||||
<title>Node1->Node5</title>
|
||||
<g id="a_edge5_Node000001_Node000005"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M91.98,-58.73C99.75,-57.72 107.98,-56.64 116.19,-55.57"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="116.39,-59.07 125.85,-54.3 115.48,-52.13 116.39,-59.07"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node6 -->
|
||||
<g id="Node000006" class="node">
|
||||
<title>Node6</title>
|
||||
<g id="a_Node000006"><a xlink:href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="215.38,-19.25 155.88,-19.25 155.88,0 215.38,0 215.38,-19.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::top</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node6 -->
|
||||
<g id="edge6_Node000001_Node000006" class="edge">
|
||||
<title>Node1->Node6</title>
|
||||
<g id="a_edge6_Node000001_Node000006"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M78.76,-48.94C93.49,-41.98 111.33,-33.95 127.75,-27.62 133.17,-25.54 138.94,-23.5 144.65,-21.59"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="145.57,-24.97 154.01,-18.57 143.42,-18.31 145.57,-24.97"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node4 -->
|
||||
<g id="Node000004" class="node">
|
||||
<title>Node4</title>
|
||||
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="373.5,-93.25 279.5,-93.25 279.5,-74 373.5,-74 373.5,-93.25"/>
|
||||
<text text-anchor="middle" x="326.5" y="-79.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::make_shared</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3->Node4 -->
|
||||
<g id="edge4_Node000003_Node000004" class="edge">
|
||||
<title>Node3->Node4</title>
|
||||
<g id="a_edge4_Node000003_Node000004"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M219.54,-83.62C234,-83.62 251.43,-83.62 267.93,-83.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="267.65,-87.13 277.65,-83.63 267.65,-80.13 267.65,-87.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 6.5 KiB |
@@ -1,121 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: graph::depth_first_search::dfs Pages: 1 -->
|
||||
<svg width="382pt" height="138pt"
|
||||
viewBox="0.00 0.00 381.50 138.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 134.25)">
|
||||
<title>graph::depth_first_search::dfs</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec...">
|
||||
<polygon fill="#999999" stroke="#666666" points="91.75,-79.88 0,-79.88 0,-49.38 91.75,-49.38 91.75,-79.88"/>
|
||||
<text text-anchor="start" x="8" y="-66.38" font-family="Helvetica,sans-Serif" font-size="10.00">graph::depth_first</text>
|
||||
<text text-anchor="middle" x="45.88" y="-55.12" font-family="Helvetica,sans-Serif" font-size="10.00">_search::dfs</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge1_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge1_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M21.11,-80.36C16.06,-89.43 24.31,-97.88 45.88,-97.88 57.67,-97.88 65.48,-95.35 69.31,-91.58"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="72.76,-92.21 70.46,-81.86 65.81,-91.38 72.76,-92.21"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="216.5,-130.25 154.75,-130.25 154.75,-111 216.5,-111 216.5,-130.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-116.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::pop</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge2_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge2_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M77.56,-80.22C92.5,-87.51 110.85,-96.01 127.75,-102.62 132.79,-104.6 138.14,-106.51 143.47,-108.31"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="142.23,-111.59 152.82,-111.36 144.4,-104.94 142.23,-111.59"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="219.12,-93.25 152.12,-93.25 152.12,-74 219.12,-74 219.12,-93.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-79.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::push</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge3_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge3_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M91.98,-70.85C107.49,-72.99 124.82,-75.38 140.27,-77.51"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="139.77,-80.97 150.15,-78.87 140.73,-74.04 139.77,-80.97"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node5 -->
|
||||
<g id="Node000005" class="node">
|
||||
<title>Node5</title>
|
||||
<g id="a_Node000005"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="243.5,-56.25 127.75,-56.25 127.75,-37 243.5,-37 243.5,-56.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node5 -->
|
||||
<g id="edge5_Node000001_Node000005" class="edge">
|
||||
<title>Node1->Node5</title>
|
||||
<g id="a_edge5_Node000001_Node000005"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M91.98,-58.73C99.75,-57.72 107.98,-56.64 116.19,-55.57"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="116.39,-59.07 125.85,-54.3 115.48,-52.13 116.39,-59.07"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node6 -->
|
||||
<g id="Node000006" class="node">
|
||||
<title>Node6</title>
|
||||
<g id="a_Node000006"><a xlink:href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="215.38,-19.25 155.88,-19.25 155.88,0 215.38,0 215.38,-19.25"/>
|
||||
<text text-anchor="middle" x="185.62" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">stack::top</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node6 -->
|
||||
<g id="edge6_Node000001_Node000006" class="edge">
|
||||
<title>Node1->Node6</title>
|
||||
<g id="a_edge6_Node000001_Node000006"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M78.76,-48.94C93.49,-41.98 111.33,-33.95 127.75,-27.62 133.17,-25.54 138.94,-23.5 144.65,-21.59"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="145.57,-24.97 154.01,-18.57 143.42,-18.31 145.57,-24.97"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node4 -->
|
||||
<g id="Node000004" class="node">
|
||||
<title>Node4</title>
|
||||
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="373.5,-93.25 279.5,-93.25 279.5,-74 373.5,-74 373.5,-93.25"/>
|
||||
<text text-anchor="middle" x="326.5" y="-79.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::make_shared</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3->Node4 -->
|
||||
<g id="edge4_Node000003_Node000004" class="edge">
|
||||
<title>Node3->Node4</title>
|
||||
<g id="a_edge4_Node000003_Node000004"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M219.54,-83.62C234,-83.62 251.43,-83.62 267.93,-83.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="267.65,-87.13 277.65,-83.63 267.65,-80.13 267.65,-87.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.7 KiB |
@@ -1,8 +0,0 @@
|
||||
<map id="main" name="main">
|
||||
<area shape="rect" id="Node000001" title="Main function." alt="" coords="5,5,55,31"/>
|
||||
<area shape="rect" id="Node000002" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="201,5,272,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="55,16,185,16,185,21,55,21"/>
|
||||
<area shape="rect" id="Node000003" href="$da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" title=" " alt="" coords="103,31,153,56"/>
|
||||
<area shape="poly" id="edge2_Node000001_Node000003" title=" " alt="" coords="56,22,89,31,87,36,54,27"/>
|
||||
<area shape="poly" id="edge3_Node000003_Node000002" title=" " alt="" coords="153,35,185,27,186,33,154,40"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
15ecf0d64cad19021d9762e4126fcb9b
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="208pt" height="46pt"
|
||||
viewBox="0.00 0.00 208.25 46.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 42.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Main function.">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-38.25 0,-38.25 0,-19 37,-19 37,-38.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-24.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="200.25,-38.25 146.75,-38.25 146.75,-19 200.25,-19 200.25,-38.25"/>
|
||||
<text text-anchor="middle" x="173.5" y="-24.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.35,-28.62C61.19,-28.62 104,-28.62 135.07,-28.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.83,-32.13 144.83,-28.63 134.83,-25.13 134.83,-32.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="110.75,-19.25 73,-19.25 73,0 110.75,0 110.75,-19.25"/>
|
||||
<text text-anchor="middle" x="91.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge2_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.14,-23.93C44.64,-21.93 53.57,-19.56 61.98,-17.32"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="62.71,-20.74 71.48,-14.79 60.91,-13.98 62.71,-20.74"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3->Node2 -->
|
||||
<g id="edge3_Node000003_Node000002" class="edge">
|
||||
<title>Node3->Node2</title>
|
||||
<g id="a_edge3_Node000003_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M110.94,-13.94C118.22,-15.67 126.89,-17.74 135.39,-19.77"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.34,-23.12 144.88,-22.03 135.96,-16.31 134.34,-23.12"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="208pt" height="46pt"
|
||||
viewBox="0.00 0.00 208.25 46.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 42.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Main function.">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-38.25 0,-38.25 0,-19 37,-19 37,-38.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-24.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="200.25,-38.25 146.75,-38.25 146.75,-19 200.25,-19 200.25,-38.25"/>
|
||||
<text text-anchor="middle" x="173.5" y="-24.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.35,-28.62C61.19,-28.62 104,-28.62 135.07,-28.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.83,-32.13 144.83,-28.63 134.83,-25.13 134.83,-32.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="110.75,-19.25 73,-19.25 73,0 110.75,0 110.75,-19.25"/>
|
||||
<text text-anchor="middle" x="91.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge2_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.14,-23.93C44.64,-21.93 53.57,-19.56 61.98,-17.32"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="62.71,-20.74 71.48,-14.79 60.91,-13.98 62.71,-20.74"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3->Node2 -->
|
||||
<g id="edge3_Node000003_Node000002" class="edge">
|
||||
<title>Node3->Node2</title>
|
||||
<g id="a_edge3_Node000003_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M110.94,-13.94C118.22,-15.67 126.89,-17.74 135.39,-19.77"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.34,-23.12 144.88,-22.03 135.96,-16.31 134.34,-23.12"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.8 KiB |
287
da/d4b/depth__first__search__with__stack_8cpp_source.html
Normal file
287
da/d4b/depth__first__search__with__stack_8cpp_source.html
Normal file
@@ -0,0 +1,287 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: graph/depth_first_search_with_stack.cpp Source File</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
<script type="text/javascript" src="../../navtree.js"></script>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../cookie.js"></script>
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&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 */
|
||||
</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 -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('da/d4b/depth__first__search__with__stack_8cpp_source.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">depth_first_search_with_stack.cpp</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<a href="../../da/d4b/depth__first__search__with__stack_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="l00032" name="l00032"></a><span class="lineno"> 32</span><span class="preprocessor">#include <iostream></span> </div>
|
||||
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="preprocessor">#include <stack></span> </div>
|
||||
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor">#include <vector></span> </div>
|
||||
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#include <cassert></span> </div>
|
||||
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor">#include <limits></span> </div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> </div>
|
||||
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#afb80b42b42381658a12a57a975ecd0c7"> 38</a></span><span class="keyword">constexpr</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#afb80b42b42381658a12a57a975ecd0c7">WHITE</a> = 0; </div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e"> 39</a></span><span class="keyword">constexpr</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a> = 1; </div>
|
||||
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b"> 40</a></span><span class="keyword">constexpr</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a> = 2; </div>
|
||||
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a330a2b0a904f01802ada1f8f3b28e76c"> 41</a></span><span class="keyword">constexpr</span> int64_t <a class="code hl_variable" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a330a2b0a904f01802ada1f8f3b28e76c">INF</a> = std::numeric_limits<int16_t>::max();</div>
|
||||
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> </div>
|
||||
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> </div>
|
||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a> {</div>
|
||||
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../d8/da7/namespacedepth__first__search.html">depth_first_search</a> {</div>
|
||||
<div class="foldopen" id="foldopen00064" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#aadebe9c855821d6515ca5b171222ef7b"> 64</a></span><span class="keywordtype">void</span> addEdge(std::vector<std::vector<size_t>> *adj, <span class="keywordtype">size_t</span> u, <span class="keywordtype">size_t</span> v) {</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'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>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> </div>
|
||||
<div class="foldopen" id="foldopen00087" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a5738da9f508f6a9e87f123c9fb6f2ea9"> 87</a></span>std::vector<size_t> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a5738da9f508f6a9e87f123c9fb6f2ea9">dfs</a>(<span class="keyword">const</span> std::vector<std::vector<size_t> > &<a class="code hl_namespace" href="../../df/dce/namespacegraph.html">graph</a>, <span class="keywordtype">size_t</span> start) {</div>
|
||||
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> std::vector<size_t> 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> std::stack<size_t> <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#a90df277532c23519aa7ac3c08ed90a1d">push</a>(start);</div>
|
||||
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> </div>
|
||||
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</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#ae09630c4384903d187801921b2ddc709">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#a3647fb4418890f19e0dc414b8092b8b0">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>) {</div>
|
||||
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> traversed_path.push_back(act + 1);</div>
|
||||
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> </div>
|
||||
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</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#a90df277532c23519aa7ac3c08ed90a1d">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>; </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>
|
||||
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span>} <span class="comment">// namespace depth_first_search</span></div>
|
||||
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span>} <span class="comment">// namespace graph</span></div>
|
||||
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> </div>
|
||||
<div class="foldopen" id="foldopen00123" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e"> 123</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>() {</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> </div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> std::cout << <span class="stringliteral">"Case 1: "</span> << std::endl;</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> std::vector<std::vector<size_t> > g1(3, std::vector<size_t>());</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> graph::depth_first_search::addEdge(&g1, 1, 2);</div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> graph::depth_first_search::addEdge(&g1, 2, 3);</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> graph::depth_first_search::addEdge(&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> std::vector<size_t> expected1 {1, 2, 3}; </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> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> </div>
|
||||
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> std::cout << <span class="stringliteral">"Case 2: "</span> << std::endl;</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> std::vector<std::vector<size_t> > g2(4, std::vector<size_t>());</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> graph::depth_first_search::addEdge(&g2, 1, 2);</div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> graph::depth_first_search::addEdge(&g2, 1, 3);</div>
|
||||
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> graph::depth_first_search::addEdge(&g2, 2, 4);</div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> graph::depth_first_search::addEdge(&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> std::vector<size_t> expected2 {1, 3, 2, 4}; </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> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> </div>
|
||||
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> std::cout << <span class="stringliteral">"Case 3: "</span> << std::endl;</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> std::vector<std::vector<size_t> > g3(4, std::vector<size_t>());</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> graph::depth_first_search::addEdge(&g3, 1, 2);</div>
|
||||
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> graph::depth_first_search::addEdge(&g3, 1, 3);</div>
|
||||
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> graph::depth_first_search::addEdge(&g3, 2, 4);</div>
|
||||
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> graph::depth_first_search::addEdge(&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> std::vector<size_t> expected3 {2, 4, 1, 3}; </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> std::cout << <span class="stringliteral">"Passed"</span> << std::endl;</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>
|
||||
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> </div>
|
||||
<div class="foldopen" id="foldopen00173" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"><a class="line" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 173</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../da/d4b/depth__first__search__with__stack_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</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> std::vector<size_t> 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> std::cout << <span class="stringliteral">"Enter the Vertices : "</span>;</div>
|
||||
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> std::cin >> vertices;</div>
|
||||
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> std::cout << <span class="stringliteral">"Enter the Edges : "</span>;</div>
|
||||
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> std::cin >> edges;</div>
|
||||
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> </div>
|
||||
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> std::vector<std::vector<size_t> > adj(vertices, std::vector<size_t>());</div>
|
||||
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> </div>
|
||||
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> std::cout << <span class="stringliteral">"Enter the vertices which have edges between them : "</span> << std::endl;</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> std::cin >> u >> v;</div>
|
||||
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> graph::depth_first_search::addEdge(&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> </div>
|
||||
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> std::cout << <span class="stringliteral">"Enter the starting vertex [1,n]: "</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> std::cin >> 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 = graph::depth_first_search::dfs(adj, start_pos);</div>
|
||||
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> </div>
|
||||
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</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> std::cout << x << <span class="charliteral">' '</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>
|
||||
<div class="ttc" id="aclassstack_html"><div class="ttname"><a href="../../d1/dc2/classstack.html">stack</a></div><div class="ttdoc">for std::invalid_argument</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00019">stack.hpp:19</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_a3647fb4418890f19e0dc414b8092b8b0"><div class="ttname"><a href="../../d1/dc2/classstack.html#a3647fb4418890f19e0dc414b8092b8b0">stack::pop</a></div><div class="ttdeci">void pop()</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00062">stack.hpp:62</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_a90df277532c23519aa7ac3c08ed90a1d"><div class="ttname"><a href="../../d1/dc2/classstack.html#a90df277532c23519aa7ac3c08ed90a1d">stack::push</a></div><div class="ttdeci">void push(const value_type &item)</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00047">stack.hpp:47</a></div></div>
|
||||
<div class="ttc" id="aclassstack_html_ae09630c4384903d187801921b2ddc709"><div class="ttname"><a href="../../d1/dc2/classstack.html#ae09630c4384903d187801921b2ddc709">stack::top</a></div><div class="ttdeci">value_type top() const</div><div class="ttdef"><b>Definition</b> <a href="../../df/d47/stack_8hpp_source.html#l00056">stack.hpp:56</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a330a2b0a904f01802ada1f8f3b28e76c"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a330a2b0a904f01802ada1f8f3b28e76c">INF</a></div><div class="ttdeci">constexpr int64_t INF</div><div class="ttdoc">indicates node has already been explored</div><div class="ttdef"><b>Definition</b> <a href="#l00041">depth_first_search_with_stack.cpp:41</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a43e30173f12330e85cce6239a277527e"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a43e30173f12330e85cce6239a277527e">GREY</a></div><div class="ttdeci">constexpr int GREY</div><div class="ttdoc">indicates the node hasn't been explored</div><div class="ttdef"><b>Definition</b> <a href="#l00039">depth_first_search_with_stack.cpp:39</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> <a href="#l00123">depth_first_search_with_stack.cpp:123</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a5738da9f508f6a9e87f123c9fb6f2ea9"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a5738da9f508f6a9e87f123c9fb6f2ea9">graph::depth_first_search::dfs</a></div><div class="ttdeci">std::vector< size_t > dfs(const std::vector< std::vector< size_t > > &graph, size_t start)</div><div class="ttdoc">Explores the given vertex, exploring a vertex means traversing over all the vertices which are connec...</div><div class="ttdef"><b>Definition</b> <a href="#l00087">depth_first_search_with_stack.cpp:87</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_a7f1cd94cf4da32933e8551cb3577e18b"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#a7f1cd94cf4da32933e8551cb3577e18b">BLACK</a></div><div class="ttdeci">constexpr int BLACK</div><div class="ttdoc">indicates node is in stack waiting to be explored</div><div class="ttdef"><b>Definition</b> <a href="#l00040">depth_first_search_with_stack.cpp:40</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_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="#l00173">depth_first_search_with_stack.cpp:173</a></div></div>
|
||||
<div class="ttc" id="adepth__first__search__with__stack_8cpp_html_afb80b42b42381658a12a57a975ecd0c7"><div class="ttname"><a href="../../da/d4b/depth__first__search__with__stack_8cpp.html#afb80b42b42381658a12a57a975ecd0c7">WHITE</a></div><div class="ttdeci">constexpr int WHITE</div><div class="ttdef"><b>Definition</b> <a href="#l00038">depth_first_search_with_stack.cpp:38</a></div></div>
|
||||
<div class="ttc" id="anamespacedepth__first__search_html"><div class="ttname"><a href="../../d8/da7/namespacedepth__first__search.html">depth_first_search</a></div><div class="ttdoc">Functions for Depth First Search algorithm.</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 class="ttc" id="aparanthesis__matching_8cpp_html_aa37d24a036d239b3b528f13b9de880c7"><div class="ttname"><a href="../../dc/dc5/paranthesis__matching_8cpp.html#aa37d24a036d239b3b528f13b9de880c7">stack</a></div><div class="ttdeci">char stack[MAX]</div><div class="ttdef"><b>Definition</b> <a href="../../dc/dc5/paranthesis__matching_8cpp_source.html#l00020">paranthesis_matching.cpp:20</a></div></div>
|
||||
</div><!-- fragment --></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_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.12.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user