<ahref="shortestpaths_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="comment">// Copyright 2010-2021 Google LLC</span></div>
<divclass="line"><aid="l00002"name="l00002"></a><spanclass="lineno"> 2</span><spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div>
<divclass="line"><aid="l00003"name="l00003"></a><spanclass="lineno"> 3</span><spanclass="comment">// you may not use this file except in compliance with the License.</span></div>
<divclass="line"><aid="l00004"name="l00004"></a><spanclass="lineno"> 4</span><spanclass="comment">// You may obtain a copy of the License at</span></div>
<divclass="line"><aid="l00008"name="l00008"></a><spanclass="lineno"> 8</span><spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<divclass="line"><aid="l00009"name="l00009"></a><spanclass="lineno"> 9</span><spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div>
<divclass="line"><aid="l00010"name="l00010"></a><spanclass="lineno"> 10</span><spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment">// See the License for the specific language governing permissions and</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment">// limitations under the License.</span></div>
<divclass="line"><aid="l00014"name="l00014"></a><spanclass="lineno"> 14</span><spanclass="comment">// This file contains various shortest paths utilities.</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span><spanclass="comment">// Dijsktra Shortest path with callback based description of the</span></div>
<divclass="line"><aid="l00033"name="l00033"></a><spanclass="lineno"> 33</span><spanclass="comment">// graph. The callback returns the distance between two nodes, a</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="comment">// distance of 'disconnected_distance' indicates no arcs between these</span></div>
<divclass="line"><aid="l00035"name="l00035"></a><spanclass="lineno"> 35</span><spanclass="comment">// two nodes. Ownership of the callback is taken by the function that</span></div>
<divclass="line"><aid="l00036"name="l00036"></a><spanclass="lineno"> 36</span><spanclass="comment">// will delete it in the end. This function returns true if</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="comment">// 'start_node' and 'end_node' are connected, false otherwise.</span></div>
<divclass="line"><aid="l00043"name="l00043"></a><spanclass="lineno"> 43</span><spanclass="comment">// Stable version of the Dijsktra Shortest path with callback based description</span></div>
<divclass="line"><aid="l00044"name="l00044"></a><spanclass="lineno"> 44</span><spanclass="comment">// of the graph. The callback returns the distance between two nodes, a</span></div>
<divclass="line"><aid="l00045"name="l00045"></a><spanclass="lineno"> 45</span><spanclass="comment">// distance of 'disconnected_distance' indicates no arcs between these</span></div>
<divclass="line"><aid="l00046"name="l00046"></a><spanclass="lineno"> 46</span><spanclass="comment">// two nodes. Ownership of the callback is taken by the function that</span></div>
<divclass="line"><aid="l00047"name="l00047"></a><spanclass="lineno"> 47</span><spanclass="comment">// will delete it in the end. This function returns true if</span></div>
<divclass="line"><aid="l00048"name="l00048"></a><spanclass="lineno"> 48</span><spanclass="comment">// 'start_node' and 'end_node' are connected, false otherwise.</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment">// Bellman-Ford Shortest path with callback-based description of the</span></div>
<divclass="line"><aid="l00055"name="l00055"></a><spanclass="lineno"> 55</span><spanclass="comment">// graph. The callback returns the distance between two nodes, a</span></div>
<divclass="line"><aid="l00056"name="l00056"></a><spanclass="lineno"> 56</span><spanclass="comment">// distance of 'disconnected_distance' indicates no arcs between these</span></div>
<divclass="line"><aid="l00057"name="l00057"></a><spanclass="lineno"> 57</span><spanclass="comment">// two nodes. Ownership of the callback is taken by the function that</span></div>
<divclass="line"><aid="l00058"name="l00058"></a><spanclass="lineno"> 58</span><spanclass="comment">// will delete it in the end. This function returns true if</span></div>
<divclass="line"><aid="l00059"name="l00059"></a><spanclass="lineno"> 59</span><spanclass="comment">// 'start_node' and 'end_node' are connected, false otherwise. If</span></div>
<divclass="line"><aid="l00060"name="l00060"></a><spanclass="lineno"> 60</span><spanclass="comment">// true, it will fill the 'nodes' vector with the sequence of nodes on</span></div>
<divclass="line"><aid="l00061"name="l00061"></a><spanclass="lineno"> 61</span><spanclass="comment">// the shortest path between 'start_node' and 'end_node'.</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span><spanclass="comment">// A* Shortest path with function based description of the</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment">// graph. The graph function returns the distance between two nodes, a</span></div>
<divclass="line"><aid="l00069"name="l00069"></a><spanclass="lineno"> 69</span><spanclass="comment">// distance of 'disconnected_distance' indicates no arcs between these</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">// two nodes. Additionally, the heuristic callback returns a</span></div>
<divclass="line"><aid="l00071"name="l00071"></a><spanclass="lineno"> 71</span><spanclass="comment">// an approximate distance between the node and the target, which guides</span></div>
<divclass="line"><aid="l00072"name="l00072"></a><spanclass="lineno"> 72</span><spanclass="comment">// the search. If the heuristic is admissible (ie. never overestimates cost),</span></div>
<divclass="line"><aid="l00073"name="l00073"></a><spanclass="lineno"> 73</span><spanclass="comment">// the A* algorithm returns an optimal solution.</span></div>
<divclass="line"><aid="l00074"name="l00074"></a><spanclass="lineno"> 74</span><spanclass="comment">// This function returns true if 'start_node' and 'end_node' are</span></div>
<divclass="ttc"id="anamespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">Collection of objects used to extend the Constraint Solver library.</div><divclass="ttdef"><b>Definition:</b><ahref="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html_a18d2a8338b0d0e7ec3852cc0b58037ed"><divclass="ttname"><ahref="namespaceoperations__research.html#a18d2a8338b0d0e7ec3852cc0b58037ed">operations_research::DijkstraShortestPath</a></div><divclass="ttdeci">bool DijkstraShortestPath(int node_count, int start_node, int end_node, std::function< int64_t(int, int)> graph, int64_t disconnected_distance, std::vector< int > *nodes)</div><divclass="ttdef"><b>Definition:</b><ahref="dijkstra_8cc_source.html#l00151">dijkstra.cc:151</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html_a40d226c5f5c250cf81ae0845a8afeb89"><divclass="ttname"><ahref="namespaceoperations__research.html#a40d226c5f5c250cf81ae0845a8afeb89">operations_research::AStarShortestPath</a></div><divclass="ttdeci">bool AStarShortestPath(int node_count, int start_node, int end_node, std::function< int64_t(int, int)> graph, std::function< int64_t(int)> heuristic, int64_t disconnected_distance, std::vector< int > *nodes)</div><divclass="ttdef"><b>Definition:</b><ahref="astar_8cc_source.html#l00170">astar.cc:170</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html_a9e9e916a0fd3a846388cc235c42d99fb"><divclass="ttname"><ahref="namespaceoperations__research.html#a9e9e916a0fd3a846388cc235c42d99fb">operations_research::StableDijkstraShortestPath</a></div><divclass="ttdeci">bool StableDijkstraShortestPath(int node_count, int start_node, int end_node, std::function< int64_t(int, int)> graph, int64_t disconnected_distance, std::vector< int > *nodes)</div><divclass="ttdef"><b>Definition:</b><ahref="dijkstra_8cc_source.html#l00160">dijkstra.cc:160</a></div></div>
<divclass="ttc"id="anamespaceoperations__research_html_ad7c912405ec283963f6a4f6dda80c674"><divclass="ttname"><ahref="namespaceoperations__research.html#ad7c912405ec283963f6a4f6dda80c674">operations_research::BellmanFordShortestPath</a></div><divclass="ttdeci">bool BellmanFordShortestPath(int node_count, int start_node, int end_node, std::function< int64_t(int, int)> graph, int64_t disconnected_distance, std::vector< int > *nodes)</div><divclass="ttdef"><b>Definition:</b><ahref="bellman__ford_8cc_source.html#l00115">bellman_ford.cc:115</a></div></div>