mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-31 01:02:46 +08:00
Documentation for 53a6c16730
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.2"/>
|
||||
<meta name="generator" content="Doxygen 1.9.3"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: graph/dijkstra.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<!-- Generated by Doxygen 1.9.3 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
@@ -98,7 +98,7 @@ $(document).ready(function(){initNavTree('d7/d1e/graph_2dijkstra_8cpp.html','../
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm"
|
||||
<p>[<a class="el" href="../../da/d9a/class_graph.html">Graph</a> Dijkstras Shortest Path Algorithm (Dijkstra's Shortest Path)] (<a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm</a>)
|
||||
<a href="#details">More...</a></p>
|
||||
<div class="textblock"><code>#include <cassert></code><br />
|
||||
<code>#include <iostream></code><br />
|
||||
@@ -140,8 +140,7 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
<tr class="separator:a330a2b0a904f01802ada1f8f3b28e76c"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p ><a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm" </p>
|
||||
<p >target="_blank" ><a class="el" href="../../da/d9a/class_graph.html">Graph</a> Dijkstras Shortest Path Algorithm (Dijkstra's Shortest Path)</p>
|
||||
<div class="textblock"><p >[<a class="el" href="../../da/d9a/class_graph.html">Graph</a> Dijkstras Shortest Path Algorithm (Dijkstra's Shortest Path)] (<a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm</a>) </p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="http://github.com/ayaankhan98" target="_blank">Ayaan Khan</a></dd></dl>
|
||||
<p>Dijkstra's Algorithm is used to find the shortest path from a source vertex to all other reachable vertex in the graph. The algorithm initially assumes all the nodes are unreachable from the given source vertex so we mark the distances of all vertices as INF (infinity) from source vertex (INF / infinity denotes unable to reach).</p>
|
||||
<p >in similar fashion with BFS we assume the distance of source vertex as 0 and pushes the vertex in a priority queue with it's distance. we maintain the priority queue as a min heap so that we can get the minimum element at the top of heap</p>
|
||||
@@ -163,35 +162,35 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Main function </p>
|
||||
<div class="fragment"><div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> {</div>
|
||||
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <span class="comment">// running predefined tests</span></div>
|
||||
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <a class="code hl_function" href="../../d7/d1e/graph_2dijkstra_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9">tests</a>();</div>
|
||||
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> </div>
|
||||
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <span class="keywordtype">int</span> vertices = int(), edges = int();</div>
|
||||
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</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 number of vertices : "</span>;</div>
|
||||
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</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"><a id="l00159" name="l00159"></a><span class="lineno"> 159</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 number of edges : "</span>;</div>
|
||||
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</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"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> </div>
|
||||
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj(</div>
|
||||
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> vertices, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> </div>
|
||||
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> <span class="keywordtype">int</span> u = int(), v = int(), w = int();</div>
|
||||
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="keywordflow">while</span> (edges--) {</div>
|
||||
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> u >> v >> w;</div>
|
||||
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj, u, v, w);</div>
|
||||
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> }</div>
|
||||
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> </div>
|
||||
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <span class="keywordtype">int</span> s = int(), t = int();</div>
|
||||
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> s >> t;</div>
|
||||
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> <span class="keywordtype">int</span> dist = <a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj, s - 1, t - 1);</div>
|
||||
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <span class="keywordflow">if</span> (dist == -1) {</div>
|
||||
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</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">"Target not reachable from source"</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"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Shortest Path Distance : "</span> << dist << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> }</div>
|
||||
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 152</span> {</div>
|
||||
<div class="line"><span class="lineno"> 153</span> <span class="comment">// running predefined tests</span></div>
|
||||
<div class="line"><span class="lineno"> 154</span> <a class="code hl_function" href="../../d7/d1e/graph_2dijkstra_8cpp.html#a88ec9ad42717780d6caaff9d3d6977f9">tests</a>();</div>
|
||||
<div class="line"><span class="lineno"> 155</span> </div>
|
||||
<div class="line"><span class="lineno"> 156</span> <span class="keywordtype">int</span> vertices = int(), edges = int();</div>
|
||||
<div class="line"><span class="lineno"> 157</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 number of vertices : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 158</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"> 159</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 number of edges : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 160</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"> 161</span> </div>
|
||||
<div class="line"><span class="lineno"> 162</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj(</div>
|
||||
<div class="line"><span class="lineno"> 163</span> vertices, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><span class="lineno"> 164</span> </div>
|
||||
<div class="line"><span class="lineno"> 165</span> <span class="keywordtype">int</span> u = int(), v = int(), w = int();</div>
|
||||
<div class="line"><span class="lineno"> 166</span> <span class="keywordflow">while</span> (edges--) {</div>
|
||||
<div class="line"><span class="lineno"> 167</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> u >> v >> w;</div>
|
||||
<div class="line"><span class="lineno"> 168</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj, u, v, w);</div>
|
||||
<div class="line"><span class="lineno"> 169</span> }</div>
|
||||
<div class="line"><span class="lineno"> 170</span> </div>
|
||||
<div class="line"><span class="lineno"> 171</span> <span class="keywordtype">int</span> s = int(), t = int();</div>
|
||||
<div class="line"><span class="lineno"> 172</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> s >> t;</div>
|
||||
<div class="line"><span class="lineno"> 173</span> <span class="keywordtype">int</span> dist = <a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj, s - 1, t - 1);</div>
|
||||
<div class="line"><span class="lineno"> 174</span> <span class="keywordflow">if</span> (dist == -1) {</div>
|
||||
<div class="line"><span class="lineno"> 175</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">"Target not reachable from source"</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"> 176</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 177</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">"Shortest Path Distance : "</span> << dist << <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"> 178</span> }</div>
|
||||
<div class="line"><span class="lineno"> 179</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 180</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="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>
|
||||
@@ -203,7 +202,7 @@ constexpr int64_t </td><td class="memItemRight" valign="bottom"><b>INF</b>
|
||||
</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="../../d7/d1e/graph_2dijkstra_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="322" height="163"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d7/d1e/graph_2dijkstra_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="486" height="163"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -224,47 +223,47 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Function to test the Algorithm </p>
|
||||
<div class="fragment"><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> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Initiatinig Predefined Tests..."</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"><a id="l00115" name="l00115"></a><span class="lineno"> 115</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">"Initiating Test 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"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj1(</div>
|
||||
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> 4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 1, 2, 1);</div>
|
||||
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 4, 1, 2);</div>
|
||||
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 2, 3, 2);</div>
|
||||
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 1, 3, 5);</div>
|
||||
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> </div>
|
||||
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> <span class="keywordtype">int</span> s = 1, t = 3;</div>
|
||||
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj1, s - 1, t - 1) == 3);</div>
|
||||
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</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">"Test 1 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"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> </div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> s = 4, t = 3;</div>
|
||||
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</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">"Initiating Test 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"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj1, s - 1, t - 1) == 5);</div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</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">"Test 2 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"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj2(</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> 5, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 1, 2, 4);</div>
|
||||
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 1, 3, 2);</div>
|
||||
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 3, 2);</div>
|
||||
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 2, 1);</div>
|
||||
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 4, 2);</div>
|
||||
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 5, 4);</div>
|
||||
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 5, 4, 1);</div>
|
||||
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 5, 3);</div>
|
||||
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 4, 4);</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> s = 1, t = 5;</div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</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">"Initiating Test 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"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj2, s - 1, t - 1) == 6);</div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</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">"Test 3 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"><a id="l00148" name="l00148"></a><span class="lineno"> 148</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">"All Test Passed..."</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 113</span> {</div>
|
||||
<div class="line"><span class="lineno"> 114</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">"Initiatinig Predefined Tests..."</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"> 115</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">"Initiating Test 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"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj1(</div>
|
||||
<div class="line"><span class="lineno"> 117</span> 4, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><span class="lineno"> 118</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 1, 2, 1);</div>
|
||||
<div class="line"><span class="lineno"> 119</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 4, 1, 2);</div>
|
||||
<div class="line"><span class="lineno"> 120</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 2, 3, 2);</div>
|
||||
<div class="line"><span class="lineno"> 121</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj1, 1, 3, 5);</div>
|
||||
<div class="line"><span class="lineno"> 122</span> </div>
|
||||
<div class="line"><span class="lineno"> 123</span> <span class="keywordtype">int</span> s = 1, t = 3;</div>
|
||||
<div class="line"><span class="lineno"> 124</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj1, s - 1, t - 1) == 3);</div>
|
||||
<div class="line"><span class="lineno"> 125</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">"Test 1 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"> 126</span> </div>
|
||||
<div class="line"><span class="lineno"> 127</span> s = 4, t = 3;</div>
|
||||
<div class="line"><span class="lineno"> 128</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">"Initiating Test 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"> 129</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj1, s - 1, t - 1) == 5);</div>
|
||||
<div class="line"><span class="lineno"> 130</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">"Test 2 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"> 131</span> </div>
|
||||
<div class="line"><span class="lineno"> 132</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<std::pair<int, int></a>>> adj2(</div>
|
||||
<div class="line"><span class="lineno"> 133</span> 5, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a><<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<int, int></a>>());</div>
|
||||
<div class="line"><span class="lineno"> 134</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 1, 2, 4);</div>
|
||||
<div class="line"><span class="lineno"> 135</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 1, 3, 2);</div>
|
||||
<div class="line"><span class="lineno"> 136</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 3, 2);</div>
|
||||
<div class="line"><span class="lineno"> 137</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 2, 1);</div>
|
||||
<div class="line"><span class="lineno"> 138</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 4, 2);</div>
|
||||
<div class="line"><span class="lineno"> 139</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 5, 4);</div>
|
||||
<div class="line"><span class="lineno"> 140</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 5, 4, 1);</div>
|
||||
<div class="line"><span class="lineno"> 141</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 2, 5, 3);</div>
|
||||
<div class="line"><span class="lineno"> 142</span> <a class="code hl_function" href="../../df/dce/namespacegraph.html#a9125ceb66bfbec3093bba64c2c1e99e2">graph::addEdge</a>(&adj2, 3, 4, 4);</div>
|
||||
<div class="line"><span class="lineno"> 143</span> </div>
|
||||
<div class="line"><span class="lineno"> 144</span> s = 1, t = 5;</div>
|
||||
<div class="line"><span class="lineno"> 145</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">"Initiating Test 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"> 146</span> assert(<a class="code hl_function" href="../../df/dce/namespacegraph.html#adc68cbc8ba09eb1142265935c0d45b84">graph::dijkstra</a>(&adj2, s - 1, t - 1) == 6);</div>
|
||||
<div class="line"><span class="lineno"> 147</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">"Test 3 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"> 148</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">"All Test Passed..."</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a> << <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"> 149</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="../../d7/d1e/graph_2dijkstra_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg" width="223" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d7/d1e/graph_2dijkstra_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg" width="387" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -276,7 +275,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li><li class="navelem"><a class="el" href="../../d7/d1e/graph_2dijkstra_8cpp.html">dijkstra.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user