Files
ortools-clone/docs/cpp/christofides_8h_source.html
2021-04-27 23:00:03 +02:00

533 lines
95 KiB
HTML

<!-- HTML header for doxygen 1.8.18-->
<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OR-Tools: christofides.h Source File</title>
<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>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="styleSheet.tmp.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 style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="orLogo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">OR-Tools
&#160;<span id="projectnumber">9.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(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:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('christofides_8h_source.html',''); initResizable(); });
/* @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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">christofides.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="christofides_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">// Copyright 2010-2021 Google LLC</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment">// you may not use this file except in compliance with the License.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment">// You may obtain a copy of the License at</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment">// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment">// See the License for the specific language governing permissions and</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment">// limitations under the License.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160; </div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment">// ChristofidesPathSolver computes an approximate solution to the Traveling</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment">// Salesman Problen using the Christofides algorithm (c.f.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment">// https://en.wikipedia.org/wiki/Christofides_algorithm).</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment">// Note that the algorithm guarantees finding a solution within 3/2 of the</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment">// optimum. Its complexity is O(n^2 * log(n)) where n is the number of nodes.</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#ifndef OR_TOOLS_GRAPH_CHRISTOFIDES_H_</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="preprocessor">#define OR_TOOLS_GRAPH_CHRISTOFIDES_H_</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="preprocessor">#include &quot;absl/status/status.h&quot;</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="preprocessor">#include &quot;absl/status/statusor.h&quot;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="integral__types_8h.html">ortools/base/integral_types.h</a>&quot;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="base_2logging_8h.html">ortools/base/logging.h</a>&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="eulerian__path_8h.html">ortools/graph/eulerian_path.h</a>&quot;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="graph_8h.html">ortools/graph/graph.h</a>&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="minimum__spanning__tree_8h.html">ortools/graph/minimum_spanning_tree.h</a>&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="perfect__matching_8h.html">ortools/graph/perfect_matching.h</a>&quot;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="linear__solver_8h.html">ortools/linear_solver/linear_solver.h</a>&quot;</span></div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="linear__solver_8pb_8h.html">ortools/linear_solver/linear_solver.pb.h</a>&quot;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="saturated__arithmetic_8h.html">ortools/util/saturated_arithmetic.h</a>&quot;</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceoperations__research.html">operations_research</a> {</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; </div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;using ::util::CompleteGraph;</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> CostType, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> = int64_t,</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> = int32_t,</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; <span class="keyword">typename</span> CostFunction = std::function&lt;CostType(<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>, <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>)&gt;&gt;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html"> 42</a></span>&#160;<span class="keyword">class </span><a class="code" href="classoperations__research_1_1_christofides_path_solver.html">ChristofidesPathSolver</a> {</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7"> 44</a></span>&#160; <span class="keyword">enum class</span> <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7">MatchingAlgorithm</a> {</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7ab66d0823917c9351a4cb68dff77f445a">MINIMUM_WEIGHT_MATCHING</a>,</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<span class="preprocessor">#if defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7a201b88f6589fa1271207fe29f583dc96">MINIMUM_WEIGHT_MATCHING_WITH_MIP</a>,</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7a99c5fe202c37dcd8ed9cc60926a4f525">MINIMAL_WEIGHT_MATCHING</a>,</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; };</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a87145cf1f5a36d27fd856596a23d495a">ChristofidesPathSolver</a>(<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> num_nodes, CostFunction costs);</div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; <span class="comment">// Sets the matching algorith to use. A minimum weight perfect matching</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <span class="comment">// (MINIMUM_WEIGHT_MATCHING) guarantees the 3/2 upper bound to the optimal</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="comment">// solution. A minimal weight perfect matching (MINIMAL_WEIGHT_MATCHING)</span></div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <span class="comment">// finds a locally minimal weight matching which does not offer any bound</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <span class="comment">// guarantee but, as of 1/2017, is orders of magnitude faster than the</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; <span class="comment">// minimum matching.</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; <span class="comment">// By default, MINIMAL_WEIGHT_MATCHING is selected.</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="comment">// TODO(user): Change the default when minimum matching gets faster.</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#ae2b64dddd58baf1bc5e01cb14971e52e"> 61</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#ae2b64dddd58baf1bc5e01cb14971e52e">SetMatchingAlgorithm</a>(<a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7">MatchingAlgorithm</a> matching) {</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; matching_ = matching;</div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; }</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; <span class="comment">// Returns the cost of the approximate TSP tour.</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; CostType <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#ab558649a26fef3a74f0909ef5af45e90">TravelingSalesmanCost</a>();</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="comment">// Returns the approximate TSP tour.</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; std::vector&lt;NodeIndex&gt; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a3076d9001536ea98d419faa81e7d8a47">TravelingSalesmanPath</a>();</div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="comment">// Runs the Christofides algorithm. Returns true if a solution was found,</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="comment">// false otherwise.</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a942f29030f08426e7e318204e987e2f7">Solve</a>();</div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <span class="comment">// Safe addition operator to avoid overflows when possible.</span></div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="comment">//template &lt;typename T&gt;</span></div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="comment">//T SafeAdd(T a, T b) {</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <span class="comment">// return a + b;</span></div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; <span class="comment">//}</span></div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; <span class="comment">//template &lt;&gt;</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; int64_t SafeAdd(int64_t <a class="code" href="constraint__solver_2table_8cc.html#acb18315d548212835cd8ed4287e6c0b6">a</a>, int64_t <a class="code" href="constraint__solver_2table_8cc.html#a9293e4d29cac928301645070dd307683">b</a>) {</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; <span class="keywordflow">return</span> <a class="code" href="namespaceoperations__research.html#a111f44b9b9cf67a8e8d83794ac9f5291">CapAdd</a>(<a class="code" href="constraint__solver_2table_8cc.html#acb18315d548212835cd8ed4287e6c0b6">a</a>, <a class="code" href="constraint__solver_2table_8cc.html#a9293e4d29cac928301645070dd307683">b</a>);</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; }</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; </div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; <span class="comment">// Matching algorithm to use.</span></div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7">MatchingAlgorithm</a> matching_;</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <span class="comment">// The complete graph on the nodes of the problem.</span></div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; CompleteGraph&lt;NodeIndex, ArcIndex&gt; graph_;</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; <span class="comment">// Function returning the cost between nodes of the problem.</span></div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keyword">const</span> CostFunction costs_;</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <span class="comment">// The cost of the computed TSP path.</span></div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; CostType tsp_cost_;</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="comment">// The path of the computed TSP,</span></div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; std::vector&lt;NodeIndex&gt; tsp_path_;</div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; </div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="comment">// True if the TSP has been solved, false otherwise.</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <span class="keywordtype">bool</span> solved_;</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160;};</div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; </div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160;<span class="comment">// Computes a minimum weight perfect matching on an undirected graph.</span></div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> WeightFunctionType, <span class="keyword">typename</span> GraphType&gt;</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160;absl::StatusOr&lt;std::vector&lt;</div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; std::pair&lt;typename GraphType::NodeIndex, typename GraphType::NodeIndex&gt;&gt;&gt;</div>
<div class="line"><a name="l00109"></a><span class="lineno"><a class="line" href="namespaceoperations__research.html#a08c4f1d4e19627689e141cf08b9f77bc"> 109</a></span>&#160;<a class="code" href="namespaceoperations__research.html#a08c4f1d4e19627689e141cf08b9f77bc">ComputeMinimumWeightMatching</a>(<span class="keyword">const</span> GraphType&amp; graph,</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; <span class="keyword">const</span> WeightFunctionType&amp; <a class="code" href="pack_8cc.html#a4255f714cea26cdd64f6a0ee72d34a8c">weight</a>) {</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; <span class="keyword">using</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> = <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">GraphType::ArcIndex</a>;</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; <span class="keyword">using</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> = <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">GraphType::NodeIndex</a>;</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; <a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html">MinCostPerfectMatching</a> matching(graph.num_nodes());</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> : graph.AllNodes()) {</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : graph.OutgoingArcs(<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>)) {</div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> = graph.Head(arc);</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; <span class="comment">// Adding both arcs is redudant for MinCostPerfectMatching.</span></div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> &lt; <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>) {</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; matching.<a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html#a132e58de7ebb46a1ba677b77f6e60907">AddEdgeWithCost</a>(<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>, <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>, <a class="code" href="pack_8cc.html#a4255f714cea26cdd64f6a0ee72d34a8c">weight</a>(arc));</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; }</div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; }</div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; }</div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; <a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html#a67a0db04d321a74b7e7fcfd3f1a3f70b">MinCostPerfectMatching::Status</a> status = matching.<a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html#a00a07ecd49cf20c2806ebbcd1f5dcbb1">Solve</a>();</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; <span class="keywordflow">if</span> (status != <a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html#a67a0db04d321a74b7e7fcfd3f1a3f70ba2579881e7c83261bc21bafb5a5c92cad">MinCostPerfectMatching::OPTIMAL</a>) {</div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; <span class="keywordflow">return</span> absl::InvalidArgumentError(<span class="stringliteral">&quot;Perfect matching failed&quot;</span>);</div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; }</div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; std::vector&lt;std::pair&lt;NodeIndex, NodeIndex&gt;&gt; match;</div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> : graph.AllNodes()) {</div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> = matching.<a class="code" href="classoperations__research_1_1_min_cost_perfect_matching.html#a14613ae615a2f7b740548dee2f3924fe">Match</a>(<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>);</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> &lt; <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>) { <span class="comment">// Both arcs are matched for a given edge, we keep one.</span></div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; match.emplace_back(<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>, <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>);</div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; }</div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; }</div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; <span class="keywordflow">return</span> match;</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160;}</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160;<span class="preprocessor">#if defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160;<span class="comment">// Computes a minimum weight perfect matching on an undirected graph using a</span></div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160;<span class="comment">// Mixed Integer Programming model.</span></div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160;<span class="comment">// TODO(user): Handle infeasible cases if this algorithm is used outside of</span></div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160;<span class="comment">// Christofides.</span></div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> WeightFunctionType, <span class="keyword">typename</span> GraphType&gt;</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160;absl::StatusOr&lt;std::vector&lt;</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; std::pair&lt;typename GraphType::NodeIndex, typename GraphType::NodeIndex&gt;&gt;&gt;</div>
<div class="line"><a name="l00145"></a><span class="lineno"><a class="line" href="namespaceoperations__research.html#a93c78280670aaeea4913d156699a403a"> 145</a></span>&#160;<a class="code" href="namespaceoperations__research.html#a93c78280670aaeea4913d156699a403a">ComputeMinimumWeightMatchingWithMIP</a>(<span class="keyword">const</span> GraphType&amp; graph,</div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; <span class="keyword">const</span> WeightFunctionType&amp; <a class="code" href="pack_8cc.html#a4255f714cea26cdd64f6a0ee72d34a8c">weight</a>) {</div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; <span class="keyword">using</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> = <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">GraphType::ArcIndex</a>;</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; <span class="keyword">using</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> = <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">GraphType::NodeIndex</a>;</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; MPModelProto <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>;</div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.set_maximize(<span class="keyword">false</span>);</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160; <span class="comment">// The model is composed of Boolean decision variables to select matching arcs</span></div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160; <span class="comment">// and constraints ensuring that each node appears in exactly one selected</span></div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; <span class="comment">// arc. The objective is to minimize the sum of the weights of selected arcs.</span></div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; <span class="comment">// It is assumed the graph is symmetrical.</span></div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; std::vector&lt;int&gt; variable_indices(graph.num_arcs(), -1);</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> node : graph.AllNodes()) {</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160; <span class="comment">// Creating arc-selection Boolean variable.</span></div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : graph.OutgoingArcs(node)) {</div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> = graph.Head(arc);</div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; <span class="keywordflow">if</span> (node &lt; <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>) {</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; variable_indices[arc] = <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.variable_size();</div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; MPVariableProto* <span class="keyword">const</span> arc_var = <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.add_variable();</div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; arc_var-&gt;set_lower_bound(0);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; arc_var-&gt;set_upper_bound(1);</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; arc_var-&gt;set_is_integer(<span class="keyword">true</span>);</div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; arc_var-&gt;set_objective_coefficient(<a class="code" href="pack_8cc.html#a4255f714cea26cdd64f6a0ee72d34a8c">weight</a>(arc));</div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; }</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; }</div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; <span class="comment">// Creating matching constraint:</span></div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; <span class="comment">// for all node i, sum(j) arc(i,j) + sum(j) arc(j,i) = 1</span></div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; MPConstraintProto* <span class="keyword">const</span> one_of_ct = <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.add_constraint();</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; one_of_ct-&gt;set_lower_bound(1);</div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; one_of_ct-&gt;set_upper_bound(1);</div>
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; }</div>
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> node : graph.AllNodes()) {</div>
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : graph.OutgoingArcs(node)) {</div>
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> = graph.Head(arc);</div>
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>&#160; <span class="keywordflow">if</span> (node &lt; <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>) {</div>
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> arc_var = variable_indices[arc];</div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160; <a class="code" href="base_2logging_8h.html#aae2dc65d9ea248d54bf39daa986dd295">DCHECK_GE</a>(arc_var, 0);</div>
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160; MPConstraintProto* one_of_ct = <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.mutable_constraint(node);</div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160; one_of_ct-&gt;add_var_index(arc_var);</div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; one_of_ct-&gt;add_coefficient(1);</div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160; one_of_ct = <a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>.mutable_constraint(<a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>);</div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160; one_of_ct-&gt;add_var_index(arc_var);</div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>&#160; one_of_ct-&gt;add_coefficient(1);</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160; }</div>
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>&#160; }</div>
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span>&#160; }</div>
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160;<span class="preprocessor">#if defined(USE_SCIP)</span></div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160; <a class="code" href="classoperations__research_1_1_m_p_solver.html">MPSolver</a> mp_solver(<span class="stringliteral">&quot;MatchingWithSCIP&quot;</span>,</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160; <a class="code" href="classoperations__research_1_1_m_p_solver.html#a76c87990aabadd148304b95332a60ff8a83b85675904f261c34c280b2abdcd9ae">MPSolver::SCIP_MIXED_INTEGER_PROGRAMMING</a>);</div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160;<span class="preprocessor">#elif defined(USE_CBC)</span></div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160; <a class="code" href="classoperations__research_1_1_m_p_solver.html">MPSolver</a> mp_solver(<span class="stringliteral">&quot;MatchingWithCBC&quot;</span>,</div>
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160; <a class="code" href="classoperations__research_1_1_m_p_solver.html#a76c87990aabadd148304b95332a60ff8ad183dc62c63346a3b984b93fbda0137a">MPSolver::CBC_MIXED_INTEGER_PROGRAMMING</a>);</div>
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; std::string error;</div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; mp_solver.<a class="code" href="classoperations__research_1_1_m_p_solver.html#ab0f83070e72cee887e874382ee6d6958">LoadModelFromProto</a>(<a class="code" href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a>, &amp;error);</div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; <a class="code" href="classoperations__research_1_1_m_p_solver.html#a573d479910e373f5d771d303e440587d">MPSolver::ResultStatus</a> status = mp_solver.<a class="code" href="classoperations__research_1_1_m_p_solver.html#acede9075c58cb2f506c99a9fe6f20303">Solve</a>();</div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; <span class="keywordflow">if</span> (status != <a class="code" href="classoperations__research_1_1_m_p_solver.html#a573d479910e373f5d771d303e440587da2579881e7c83261bc21bafb5a5c92cad">MPSolver::OPTIMAL</a>) {</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <span class="keywordflow">return</span> absl::InvalidArgumentError(<span class="stringliteral">&quot;MIP-based matching failed&quot;</span>);</div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; }</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; MPSolutionResponse <a class="code" href="cp__model__solver_8cc.html#abcd33b18ce6d5a90a4ba5c37cfa58829">response</a>;</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; mp_solver.<a class="code" href="classoperations__research_1_1_m_p_solver.html#a018794097e44ee8189380eef2b0f267f">FillSolutionResponseProto</a>(&amp;<a class="code" href="cp__model__solver_8cc.html#abcd33b18ce6d5a90a4ba5c37cfa58829">response</a>);</div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; std::vector&lt;std::pair&lt;NodeIndex, NodeIndex&gt;&gt; matching;</div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc = 0; arc &lt; variable_indices.size(); ++arc) {</div>
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> arc_var = variable_indices[arc];</div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; <span class="keywordflow">if</span> (arc_var &gt;= 0 &amp;&amp; <a class="code" href="cp__model__solver_8cc.html#abcd33b18ce6d5a90a4ba5c37cfa58829">response</a>.variable_value(arc_var) &gt; .9) {</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; <a class="code" href="base_2logging_8h.html#aae2dc65d9ea248d54bf39daa986dd295">DCHECK_GE</a>(<a class="code" href="cp__model__solver_8cc.html#abcd33b18ce6d5a90a4ba5c37cfa58829">response</a>.variable_value(arc_var), 1.0 - 1e-4);</div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; matching.emplace_back(graph.Tail(arc), graph.Head(arc));</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; }</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; }</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; <span class="keywordflow">return</span> matching;</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160;}</div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; </div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> CostType, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; <span class="keyword">typename</span> CostFunction&gt;</div>
<div class="line"><a name="l00219"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#a87145cf1f5a36d27fd856596a23d495a"> 219</a></span>&#160;<a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a87145cf1f5a36d27fd856596a23d495a">ChristofidesPathSolver&lt;CostType, ArcIndex, NodeIndex, CostFunction&gt;::</a></div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160;<a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a87145cf1f5a36d27fd856596a23d495a"> ChristofidesPathSolver</a>(<a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> num_nodes, CostFunction costs)</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; : matching_(<a class="code" href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7">MatchingAlgorithm</a>::MINIMAL_WEIGHT_MATCHING),</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; graph_(num_nodes),</div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; costs_(std::move(costs)),</div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; tsp_cost_(0),</div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; solved_(false) {}</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; </div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> CostType, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <span class="keyword">typename</span> CostFunction&gt;</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160;CostType <a class="code" href="classoperations__research_1_1_christofides_path_solver.html">ChristofidesPathSolver</a>&lt;CostType, <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00230"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#ab558649a26fef3a74f0909ef5af45e90"> 230</a></span>&#160; CostFunction&gt;::TravelingSalesmanCost() {</div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160; <span class="keywordflow">if</span> (!solved_) {</div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; <span class="keywordtype">bool</span> <span class="keyword">const</span> ok = <a class="code" href="namespaceoperations__research_1_1sat.html#af904018d9a1c9983624b1ce0331f2bf5">Solve</a>();</div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; <a class="code" href="base_2logging_8h.html#ae17f8119c108cf3070bad3449c7e0006">DCHECK</a>(ok);</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; }</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="keywordflow">return</span> tsp_cost_;</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160;}</div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; </div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> CostType, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; <span class="keyword">typename</span> CostFunction&gt;</div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160;std::vector&lt;NodeIndex&gt; <a class="code" href="classoperations__research_1_1_christofides_path_solver.html">ChristofidesPathSolver</a>&lt;</div>
<div class="line"><a name="l00241"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#a3076d9001536ea98d419faa81e7d8a47"> 241</a></span>&#160; CostType, <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>, CostFunction&gt;::TravelingSalesmanPath() {</div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; <span class="keywordflow">if</span> (!solved_) {</div>
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; <span class="keyword">const</span> <span class="keywordtype">bool</span> ok = <a class="code" href="namespaceoperations__research_1_1sat.html#af904018d9a1c9983624b1ce0331f2bf5">Solve</a>();</div>
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; <a class="code" href="base_2logging_8h.html#ae17f8119c108cf3070bad3449c7e0006">DCHECK</a>(ok);</div>
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; }</div>
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>&#160; <span class="keywordflow">return</span> tsp_path_;</div>
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160;}</div>
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; </div>
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> CostType, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <span class="keyword">typename</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00250"></a><span class="lineno"> 250</span>&#160; <span class="keyword">typename</span> CostFunction&gt;</div>
<div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160;<span class="keywordtype">bool</span> <a class="code" href="classoperations__research_1_1_christofides_path_solver.html">ChristofidesPathSolver</a>&lt;CostType, <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a>, <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a>,</div>
<div class="line"><a name="l00252"></a><span class="lineno"><a class="line" href="classoperations__research_1_1_christofides_path_solver.html#a942f29030f08426e7e318204e987e2f7"> 252</a></span>&#160; CostFunction&gt;<a class="code" href="namespaceoperations__research_1_1sat.html#af904018d9a1c9983624b1ce0331f2bf5">::Solve</a>() {</div>
<div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> num_nodes = graph_.num_nodes();</div>
<div class="line"><a name="l00254"></a><span class="lineno"> 254</span>&#160; tsp_path_.clear();</div>
<div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; tsp_cost_ = 0;</div>
<div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; <span class="keywordflow">if</span> (num_nodes == 1) {</div>
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; tsp_path_ = {0, 0};</div>
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; }</div>
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; <span class="keywordflow">if</span> (num_nodes &lt;= 1) {</div>
<div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; }</div>
<div class="line"><a name="l00262"></a><span class="lineno"> 262</span>&#160; <span class="comment">// Compute Minimum Spanning Tree.</span></div>
<div class="line"><a name="l00263"></a><span class="lineno"> 263</span>&#160; <span class="keyword">const</span> std::vector&lt;ArcIndex&gt; mst =</div>
<div class="line"><a name="l00264"></a><span class="lineno"> 264</span>&#160; <a class="code" href="namespaceoperations__research.html#a33a2f4c26fd60cd0fa98257b571c974f">BuildPrimMinimumSpanningTree</a>(graph_, [<span class="keyword">this</span>](<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc) {</div>
<div class="line"><a name="l00265"></a><span class="lineno"> 265</span>&#160; <span class="keywordflow">return</span> costs_(graph_.Tail(arc), graph_.Head(arc));</div>
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160; });</div>
<div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160; <span class="comment">// Detect odd degree nodes.</span></div>
<div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160; std::vector&lt;NodeIndex&gt; degrees(num_nodes, 0);</div>
<div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : mst) {</div>
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; degrees[graph_.Tail(arc)]++;</div>
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160; degrees[graph_.Head(arc)]++;</div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; }</div>
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160; std::vector&lt;NodeIndex&gt; odd_degree_nodes;</div>
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; degrees.size(); ++i) {</div>
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160; <span class="keywordflow">if</span> (degrees[i] % 2 != 0) {</div>
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span>&#160; odd_degree_nodes.push_back(i);</div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160; }</div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160; }</div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160; <span class="comment">// Find minimum-weight perfect matching on odd-degree-node complete graph.</span></div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160; <span class="comment">// TODO(user): Make this code available as an independent algorithm.</span></div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> reduced_size = odd_degree_nodes.size();</div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160; <a class="code" href="base_2logging_8h.html#a46e69120fbd3b36e6960e096d23b66f0">DCHECK_NE</a>(0, reduced_size);</div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160; CompleteGraph&lt;NodeIndex, ArcIndex&gt; reduced_graph(reduced_size);</div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; std::vector&lt;std::pair&lt;NodeIndex, NodeIndex&gt;&gt; closure_arcs;</div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; <span class="keywordflow">switch</span> (matching_) {</div>
<div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; <span class="keywordflow">case</span> MatchingAlgorithm::MINIMUM_WEIGHT_MATCHING: {</div>
<div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160; <span class="keyword">auto</span> result = <a class="code" href="namespaceoperations__research.html#a08c4f1d4e19627689e141cf08b9f77bc">ComputeMinimumWeightMatching</a>(</div>
<div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160; reduced_graph, [<span class="keyword">this</span>, &amp;reduced_graph,</div>
<div class="line"><a name="l00289"></a><span class="lineno"> 289</span>&#160; &amp;odd_degree_nodes](<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">CompleteGraph&lt;&gt;::ArcIndex</a> arc) {</div>
<div class="line"><a name="l00290"></a><span class="lineno"> 290</span>&#160; <span class="keywordflow">return</span> costs_(odd_degree_nodes[reduced_graph.Tail(arc)],</div>
<div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160; odd_degree_nodes[reduced_graph.Head(arc)]);</div>
<div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160; });</div>
<div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160; <span class="keywordflow">if</span> (!result.ok()) {</div>
<div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160; <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00295"></a><span class="lineno"> 295</span>&#160; }</div>
<div class="line"><a name="l00296"></a><span class="lineno"> 296</span>&#160; result-&gt;swap(closure_arcs);</div>
<div class="line"><a name="l00297"></a><span class="lineno"> 297</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>&#160; }</div>
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>&#160;<span class="preprocessor">#if defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160; <span class="keywordflow">case</span> MatchingAlgorithm::MINIMUM_WEIGHT_MATCHING_WITH_MIP: {</div>
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>&#160; <span class="keyword">auto</span> result = <a class="code" href="namespaceoperations__research.html#a93c78280670aaeea4913d156699a403a">ComputeMinimumWeightMatchingWithMIP</a>(</div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>&#160; reduced_graph, [<span class="keyword">this</span>, &amp;reduced_graph,</div>
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>&#160; &amp;odd_degree_nodes](<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">CompleteGraph&lt;&gt;::ArcIndex</a> arc) {</div>
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>&#160; <span class="keywordflow">return</span> costs_(odd_degree_nodes[reduced_graph.Tail(arc)],</div>
<div class="line"><a name="l00305"></a><span class="lineno"> 305</span>&#160; odd_degree_nodes[reduced_graph.Head(arc)]);</div>
<div class="line"><a name="l00306"></a><span class="lineno"> 306</span>&#160; });</div>
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>&#160; <span class="keywordflow">if</span> (!result.ok()) {</div>
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>&#160; <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>&#160; }</div>
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>&#160; result-&gt;swap(closure_arcs);</div>
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span>&#160; }</div>
<div class="line"><a name="l00313"></a><span class="lineno"> 313</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// defined(USE_CBC) || defined(USE_SCIP)</span></div>
<div class="line"><a name="l00314"></a><span class="lineno"> 314</span>&#160; <span class="keywordflow">case</span> MatchingAlgorithm::MINIMAL_WEIGHT_MATCHING: {</div>
<div class="line"><a name="l00315"></a><span class="lineno"> 315</span>&#160; <span class="comment">// TODO(user): Cost caching was added and can gain up to 20% but</span></div>
<div class="line"><a name="l00316"></a><span class="lineno"> 316</span>&#160; <span class="comment">// increases memory usage; see if we can avoid caching.</span></div>
<div class="line"><a name="l00317"></a><span class="lineno"> 317</span>&#160; std::vector&lt;ArcIndex&gt; ordered_arcs(reduced_graph.num_arcs());</div>
<div class="line"><a name="l00318"></a><span class="lineno"> 318</span>&#160; std::vector&lt;CostType&gt; ordered_arc_costs(reduced_graph.num_arcs(), 0);</div>
<div class="line"><a name="l00319"></a><span class="lineno"> 319</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : reduced_graph.AllForwardArcs()) {</div>
<div class="line"><a name="l00320"></a><span class="lineno"> 320</span>&#160; ordered_arcs[arc] = arc;</div>
<div class="line"><a name="l00321"></a><span class="lineno"> 321</span>&#160; ordered_arc_costs[arc] =</div>
<div class="line"><a name="l00322"></a><span class="lineno"> 322</span>&#160; costs_(odd_degree_nodes[reduced_graph.Tail(arc)],</div>
<div class="line"><a name="l00323"></a><span class="lineno"> 323</span>&#160; odd_degree_nodes[reduced_graph.Head(arc)]);</div>
<div class="line"><a name="l00324"></a><span class="lineno"> 324</span>&#160; }</div>
<div class="line"><a name="l00325"></a><span class="lineno"> 325</span>&#160; std::sort(ordered_arcs.begin(), ordered_arcs.end(),</div>
<div class="line"><a name="l00326"></a><span class="lineno"> 326</span>&#160; [&amp;ordered_arc_costs](<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc_a, <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc_b) {</div>
<div class="line"><a name="l00327"></a><span class="lineno"> 327</span>&#160; return ordered_arc_costs[arc_a] &lt; ordered_arc_costs[arc_b];</div>
<div class="line"><a name="l00328"></a><span class="lineno"> 328</span>&#160; });</div>
<div class="line"><a name="l00329"></a><span class="lineno"> 329</span>&#160; std::vector&lt;bool&gt; touched_nodes(reduced_size, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00330"></a><span class="lineno"> 330</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc_index = 0; closure_arcs.size() * 2 &lt; reduced_size;</div>
<div class="line"><a name="l00331"></a><span class="lineno"> 331</span>&#160; ++arc_index) {</div>
<div class="line"><a name="l00332"></a><span class="lineno"> 332</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc = ordered_arcs[arc_index];</div>
<div class="line"><a name="l00333"></a><span class="lineno"> 333</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> = reduced_graph.Tail(arc);</div>
<div class="line"><a name="l00334"></a><span class="lineno"> 334</span>&#160; <span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> = reduced_graph.Head(arc);</div>
<div class="line"><a name="l00335"></a><span class="lineno"> 335</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a> != <a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a> &amp;&amp; !touched_nodes[<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>] &amp;&amp; !touched_nodes[<a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>]) {</div>
<div class="line"><a name="l00336"></a><span class="lineno"> 336</span>&#160; touched_nodes[<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>] = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00337"></a><span class="lineno"> 337</span>&#160; touched_nodes[<a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>] = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00338"></a><span class="lineno"> 338</span>&#160; closure_arcs.emplace_back(<a class="code" href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a>, <a class="code" href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a>);</div>
<div class="line"><a name="l00339"></a><span class="lineno"> 339</span>&#160; }</div>
<div class="line"><a name="l00340"></a><span class="lineno"> 340</span>&#160; }</div>
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>&#160; }</div>
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>&#160; }</div>
<div class="line"><a name="l00344"></a><span class="lineno"> 344</span>&#160; <span class="comment">// Build Eulerian path on minimum spanning tree + closing edges from matching</span></div>
<div class="line"><a name="l00345"></a><span class="lineno"> 345</span>&#160; <span class="comment">// and extract a solution to the Traveling Salesman from the path by skipping</span></div>
<div class="line"><a name="l00346"></a><span class="lineno"> 346</span>&#160; <span class="comment">// duplicate nodes.</span></div>
<div class="line"><a name="l00347"></a><span class="lineno"> 347</span>&#160; <a class="code" href="classutil_1_1_reverse_arc_list_graph.html">::util::ReverseArcListGraph&lt;NodeIndex, ArcIndex&gt;</a> egraph(</div>
<div class="line"><a name="l00348"></a><span class="lineno"> 348</span>&#160; num_nodes, closure_arcs.size() + mst.size());</div>
<div class="line"><a name="l00349"></a><span class="lineno"> 349</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">ArcIndex</a> arc : mst) {</div>
<div class="line"><a name="l00350"></a><span class="lineno"> 350</span>&#160; egraph.<a class="code" href="classutil_1_1_reverse_arc_list_graph.html#a7b505ba4a01bce342d049f5a8674da72">AddArc</a>(graph_.Tail(arc), graph_.Head(arc));</div>
<div class="line"><a name="l00351"></a><span class="lineno"> 351</span>&#160; }</div>
<div class="line"><a name="l00352"></a><span class="lineno"> 352</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> arc : closure_arcs) {</div>
<div class="line"><a name="l00353"></a><span class="lineno"> 353</span>&#160; egraph.<a class="code" href="classutil_1_1_reverse_arc_list_graph.html#a7b505ba4a01bce342d049f5a8674da72">AddArc</a>(odd_degree_nodes[arc.first], odd_degree_nodes[arc.second]);</div>
<div class="line"><a name="l00354"></a><span class="lineno"> 354</span>&#160; }</div>
<div class="line"><a name="l00355"></a><span class="lineno"> 355</span>&#160; std::vector&lt;bool&gt; touched(num_nodes, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00356"></a><span class="lineno"> 356</span>&#160; <a class="code" href="base_2logging_8h.html#ae17f8119c108cf3070bad3449c7e0006">DCHECK</a>(<a class="code" href="namespaceoperations__research.html#ab1cf773de0cae72d0c44efe5b8f4bb89">IsEulerianGraph</a>(egraph));</div>
<div class="line"><a name="l00357"></a><span class="lineno"> 357</span>&#160; <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">NodeIndex</a> node : <a class="code" href="namespaceoperations__research.html#aa63055860fc53f8eed56d23d2571c180">BuildEulerianTourFromNode</a>(egraph, 0)) {</div>
<div class="line"><a name="l00358"></a><span class="lineno"> 358</span>&#160; <span class="keywordflow">if</span> (touched[node]) <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00359"></a><span class="lineno"> 359</span>&#160; touched[node] = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00360"></a><span class="lineno"> 360</span>&#160; tsp_cost_ = SafeAdd(tsp_cost_,</div>
<div class="line"><a name="l00361"></a><span class="lineno"> 361</span>&#160; tsp_path_.empty() ? 0 : costs_(tsp_path_.back(), node));</div>
<div class="line"><a name="l00362"></a><span class="lineno"> 362</span>&#160; tsp_path_.push_back(node);</div>
<div class="line"><a name="l00363"></a><span class="lineno"> 363</span>&#160; }</div>
<div class="line"><a name="l00364"></a><span class="lineno"> 364</span>&#160; tsp_cost_ =</div>
<div class="line"><a name="l00365"></a><span class="lineno"> 365</span>&#160; SafeAdd(tsp_cost_, tsp_path_.empty() ? 0 : costs_(tsp_path_.back(), 0));</div>
<div class="line"><a name="l00366"></a><span class="lineno"> 366</span>&#160; tsp_path_.push_back(0);</div>
<div class="line"><a name="l00367"></a><span class="lineno"> 367</span>&#160; solved_ = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00368"></a><span class="lineno"> 368</span>&#160; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00369"></a><span class="lineno"> 369</span>&#160;}</div>
<div class="line"><a name="l00370"></a><span class="lineno"> 370</span>&#160;} <span class="comment">// namespace operations_research</span></div>
<div class="line"><a name="l00371"></a><span class="lineno"> 371</span>&#160; </div>
<div class="line"><a name="l00372"></a><span class="lineno"> 372</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// OR_TOOLS_GRAPH_CHRISTOFIDES_H_</span></div>
<div class="ttc" id="abase_2logging_8h_html"><div class="ttname"><a href="base_2logging_8h.html">logging.h</a></div></div>
<div class="ttc" id="abase_2logging_8h_html_a46e69120fbd3b36e6960e096d23b66f0"><div class="ttname"><a href="base_2logging_8h.html#a46e69120fbd3b36e6960e096d23b66f0">DCHECK_NE</a></div><div class="ttdeci">#define DCHECK_NE(val1, val2)</div><div class="ttdef"><b>Definition:</b> <a href="base_2logging_8h_source.html#l00894">base/logging.h:894</a></div></div>
<div class="ttc" id="abase_2logging_8h_html_aae2dc65d9ea248d54bf39daa986dd295"><div class="ttname"><a href="base_2logging_8h.html#aae2dc65d9ea248d54bf39daa986dd295">DCHECK_GE</a></div><div class="ttdeci">#define DCHECK_GE(val1, val2)</div><div class="ttdef"><b>Definition:</b> <a href="base_2logging_8h_source.html#l00897">base/logging.h:897</a></div></div>
<div class="ttc" id="abase_2logging_8h_html_ae17f8119c108cf3070bad3449c7e0006"><div class="ttname"><a href="base_2logging_8h.html#ae17f8119c108cf3070bad3449c7e0006">DCHECK</a></div><div class="ttdeci">#define DCHECK(condition)</div><div class="ttdef"><b>Definition:</b> <a href="base_2logging_8h_source.html#l00892">base/logging.h:892</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html">operations_research::ChristofidesPathSolver</a></div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00042">christofides.h:42</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a1d4f082de5fc3eed348d65eb30b5f3e7"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7">operations_research::ChristofidesPathSolver::MatchingAlgorithm</a></div><div class="ttdeci">MatchingAlgorithm</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00044">christofides.h:44</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a1d4f082de5fc3eed348d65eb30b5f3e7a201b88f6589fa1271207fe29f583dc96"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7a201b88f6589fa1271207fe29f583dc96">operations_research::ChristofidesPathSolver::MatchingAlgorithm::MINIMUM_WEIGHT_MATCHING_WITH_MIP</a></div><div class="ttdeci">@ MINIMUM_WEIGHT_MATCHING_WITH_MIP</div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a1d4f082de5fc3eed348d65eb30b5f3e7a99c5fe202c37dcd8ed9cc60926a4f525"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7a99c5fe202c37dcd8ed9cc60926a4f525">operations_research::ChristofidesPathSolver::MatchingAlgorithm::MINIMAL_WEIGHT_MATCHING</a></div><div class="ttdeci">@ MINIMAL_WEIGHT_MATCHING</div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a1d4f082de5fc3eed348d65eb30b5f3e7ab66d0823917c9351a4cb68dff77f445a"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a1d4f082de5fc3eed348d65eb30b5f3e7ab66d0823917c9351a4cb68dff77f445a">operations_research::ChristofidesPathSolver::MatchingAlgorithm::MINIMUM_WEIGHT_MATCHING</a></div><div class="ttdeci">@ MINIMUM_WEIGHT_MATCHING</div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a3076d9001536ea98d419faa81e7d8a47"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a3076d9001536ea98d419faa81e7d8a47">operations_research::ChristofidesPathSolver::TravelingSalesmanPath</a></div><div class="ttdeci">std::vector&lt; NodeIndex &gt; TravelingSalesmanPath()</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00241">christofides.h:241</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a87145cf1f5a36d27fd856596a23d495a"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a87145cf1f5a36d27fd856596a23d495a">operations_research::ChristofidesPathSolver::ChristofidesPathSolver</a></div><div class="ttdeci">ChristofidesPathSolver(NodeIndex num_nodes, CostFunction costs)</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00219">christofides.h:220</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_a942f29030f08426e7e318204e987e2f7"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#a942f29030f08426e7e318204e987e2f7">operations_research::ChristofidesPathSolver::Solve</a></div><div class="ttdeci">bool Solve()</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00252">christofides.h:252</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_ab558649a26fef3a74f0909ef5af45e90"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#ab558649a26fef3a74f0909ef5af45e90">operations_research::ChristofidesPathSolver::TravelingSalesmanCost</a></div><div class="ttdeci">CostType TravelingSalesmanCost()</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00230">christofides.h:230</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_christofides_path_solver_html_ae2b64dddd58baf1bc5e01cb14971e52e"><div class="ttname"><a href="classoperations__research_1_1_christofides_path_solver.html#ae2b64dddd58baf1bc5e01cb14971e52e">operations_research::ChristofidesPathSolver::SetMatchingAlgorithm</a></div><div class="ttdeci">void SetMatchingAlgorithm(MatchingAlgorithm matching)</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00061">christofides.h:61</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html">operations_research::MPSolver</a></div><div class="ttdoc">This mathematical programming (MP) solver class is the main class though which users build and solve ...</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8h_source.html#l00181">linear_solver.h:181</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_a018794097e44ee8189380eef2b0f267f"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#a018794097e44ee8189380eef2b0f267f">operations_research::MPSolver::FillSolutionResponseProto</a></div><div class="ttdeci">void FillSolutionResponseProto(MPSolutionResponse *response) const</div><div class="ttdoc">Encodes the current solution in a solution response protocol buffer.</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8cc_source.html#l00814">linear_solver.cc:814</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_a573d479910e373f5d771d303e440587d"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#a573d479910e373f5d771d303e440587d">operations_research::MPSolver::ResultStatus</a></div><div class="ttdeci">ResultStatus</div><div class="ttdoc">The status of solving the problem.</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8h_source.html#l00437">linear_solver.h:437</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_a573d479910e373f5d771d303e440587da2579881e7c83261bc21bafb5a5c92cad"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#a573d479910e373f5d771d303e440587da2579881e7c83261bc21bafb5a5c92cad">operations_research::MPSolver::OPTIMAL</a></div><div class="ttdeci">@ OPTIMAL</div><div class="ttdoc">optimal.</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8h_source.html#l00439">linear_solver.h:439</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_a76c87990aabadd148304b95332a60ff8a83b85675904f261c34c280b2abdcd9ae"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#a76c87990aabadd148304b95332a60ff8a83b85675904f261c34c280b2abdcd9ae">operations_research::MPSolver::SCIP_MIXED_INTEGER_PROGRAMMING</a></div><div class="ttdeci">@ SCIP_MIXED_INTEGER_PROGRAMMING</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8h_source.html#l00198">linear_solver.h:198</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_a76c87990aabadd148304b95332a60ff8ad183dc62c63346a3b984b93fbda0137a"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#a76c87990aabadd148304b95332a60ff8ad183dc62c63346a3b984b93fbda0137a">operations_research::MPSolver::CBC_MIXED_INTEGER_PROGRAMMING</a></div><div class="ttdeci">@ CBC_MIXED_INTEGER_PROGRAMMING</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8h_source.html#l00200">linear_solver.h:200</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_ab0f83070e72cee887e874382ee6d6958"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#ab0f83070e72cee887e874382ee6d6958">operations_research::MPSolver::LoadModelFromProto</a></div><div class="ttdeci">MPSolverResponseStatus LoadModelFromProto(const MPModelProto &amp;input_model, std::string *error_message)</div><div class="ttdoc">Loads model from protocol buffer.</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8cc_source.html#l00640">linear_solver.cc:640</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_m_p_solver_html_acede9075c58cb2f506c99a9fe6f20303"><div class="ttname"><a href="classoperations__research_1_1_m_p_solver.html#acede9075c58cb2f506c99a9fe6f20303">operations_research::MPSolver::Solve</a></div><div class="ttdeci">ResultStatus Solve()</div><div class="ttdoc">Solves the problem using the default parameter values.</div><div class="ttdef"><b>Definition:</b> <a href="linear__solver_8cc_source.html#l01254">linear_solver.cc:1254</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html">operations_research::MinCostPerfectMatching</a></div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8h_source.html#l00050">perfect_matching.h:50</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html_a00a07ecd49cf20c2806ebbcd1f5dcbb1"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html#a00a07ecd49cf20c2806ebbcd1f5dcbb1">operations_research::MinCostPerfectMatching::Solve</a></div><div class="ttdeci">ABSL_MUST_USE_RESULT Status Solve()</div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8cc_source.html#l00039">perfect_matching.cc:39</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html_a132e58de7ebb46a1ba677b77f6e60907"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html#a132e58de7ebb46a1ba677b77f6e60907">operations_research::MinCostPerfectMatching::AddEdgeWithCost</a></div><div class="ttdeci">void AddEdgeWithCost(int tail, int head, int64_t cost)</div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8cc_source.html#l00027">perfect_matching.cc:27</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html_a14613ae615a2f7b740548dee2f3924fe"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html#a14613ae615a2f7b740548dee2f3924fe">operations_research::MinCostPerfectMatching::Match</a></div><div class="ttdeci">int Match(int node) const</div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8h_source.html#l00109">perfect_matching.h:109</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html_a67a0db04d321a74b7e7fcfd3f1a3f70b"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html#a67a0db04d321a74b7e7fcfd3f1a3f70b">operations_research::MinCostPerfectMatching::Status</a></div><div class="ttdeci">Status</div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8h_source.html#l00081">perfect_matching.h:81</a></div></div>
<div class="ttc" id="aclassoperations__research_1_1_min_cost_perfect_matching_html_a67a0db04d321a74b7e7fcfd3f1a3f70ba2579881e7c83261bc21bafb5a5c92cad"><div class="ttname"><a href="classoperations__research_1_1_min_cost_perfect_matching.html#a67a0db04d321a74b7e7fcfd3f1a3f70ba2579881e7c83261bc21bafb5a5c92cad">operations_research::MinCostPerfectMatching::OPTIMAL</a></div><div class="ttdeci">@ OPTIMAL</div><div class="ttdef"><b>Definition:</b> <a href="perfect__matching_8h_source.html#l00083">perfect_matching.h:83</a></div></div>
<div class="ttc" id="aclassutil_1_1_reverse_arc_list_graph_html"><div class="ttname"><a href="classutil_1_1_reverse_arc_list_graph.html">util::ReverseArcListGraph</a></div><div class="ttdef"><b>Definition:</b> <a href="graph_8h_source.html#l00461">graph.h:462</a></div></div>
<div class="ttc" id="aclassutil_1_1_reverse_arc_list_graph_html_a7b505ba4a01bce342d049f5a8674da72"><div class="ttname"><a href="classutil_1_1_reverse_arc_list_graph.html#a7b505ba4a01bce342d049f5a8674da72">util::ReverseArcListGraph::AddArc</a></div><div class="ttdeci">ArcIndexType AddArc(NodeIndexType tail, NodeIndexType head)</div><div class="ttdef"><b>Definition:</b> <a href="graph_8h_source.html#l01507">graph.h:1507</a></div></div>
<div class="ttc" id="aconstraint__solver_2table_8cc_html_a9293e4d29cac928301645070dd307683"><div class="ttname"><a href="constraint__solver_2table_8cc.html#a9293e4d29cac928301645070dd307683">b</a></div><div class="ttdeci">int64_t b</div><div class="ttdef"><b>Definition:</b> <a href="constraint__solver_2table_8cc_source.html#l00047">constraint_solver/table.cc:47</a></div></div>
<div class="ttc" id="aconstraint__solver_2table_8cc_html_acb18315d548212835cd8ed4287e6c0b6"><div class="ttname"><a href="constraint__solver_2table_8cc.html#acb18315d548212835cd8ed4287e6c0b6">a</a></div><div class="ttdeci">int64_t a</div><div class="ttdef"><b>Definition:</b> <a href="constraint__solver_2table_8cc_source.html#l00046">constraint_solver/table.cc:46</a></div></div>
<div class="ttc" id="acp__model__solver_8cc_html_abcd33b18ce6d5a90a4ba5c37cfa58829"><div class="ttname"><a href="cp__model__solver_8cc.html#abcd33b18ce6d5a90a4ba5c37cfa58829">response</a></div><div class="ttdeci">SharedResponseManager * response</div><div class="ttdef"><b>Definition:</b> <a href="cp__model__solver_8cc_source.html#l02154">cp_model_solver.cc:2154</a></div></div>
<div class="ttc" id="aeulerian__path_8h_html"><div class="ttname"><a href="eulerian__path_8h.html">eulerian_path.h</a></div></div>
<div class="ttc" id="agraph_8h_html"><div class="ttname"><a href="graph_8h.html">graph.h</a></div></div>
<div class="ttc" id="agurobi__interface_8cc_html_a0728f23c9a47655d38e0bf1a2f200bcf"><div class="ttname"><a href="gurobi__interface_8cc.html#a0728f23c9a47655d38e0bf1a2f200bcf">model</a></div><div class="ttdeci">GRBmodel * model</div><div class="ttdef"><b>Definition:</b> <a href="gurobi__interface_8cc_source.html#l00273">gurobi_interface.cc:273</a></div></div>
<div class="ttc" id="aintegral__types_8h_html"><div class="ttname"><a href="integral__types_8h.html">integral_types.h</a></div></div>
<div class="ttc" id="alinear__solver_8h_html"><div class="ttname"><a href="linear__solver_8h.html">linear_solver.h</a></div><div class="ttdoc">A C++ wrapper that provides a simple and unified interface to several linear programming and mixed in...</div></div>
<div class="ttc" id="alinear__solver_8pb_8h_html"><div class="ttname"><a href="linear__solver_8pb_8h.html">linear_solver.pb.h</a></div></div>
<div class="ttc" id="aminimum__spanning__tree_8h_html"><div class="ttname"><a href="minimum__spanning__tree_8h.html">minimum_spanning_tree.h</a></div></div>
<div class="ttc" id="anamespaceoperations__research_1_1sat_html_af904018d9a1c9983624b1ce0331f2bf5"><div class="ttname"><a href="namespaceoperations__research_1_1sat.html#af904018d9a1c9983624b1ce0331f2bf5">operations_research::sat::Solve</a></div><div class="ttdeci">CpSolverResponse Solve(const CpModelProto &amp;model_proto)</div><div class="ttdoc">Solves the given CpModelProto and returns an instance of CpSolverResponse.</div><div class="ttdef"><b>Definition:</b> <a href="cp__model__solver_8cc_source.html#l03361">cp_model_solver.cc:3361</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html"><div class="ttname"><a href="namespaceoperations__research.html">operations_research</a></div><div class="ttdoc">Collection of objects used to extend the Constraint Solver library.</div><div class="ttdef"><b>Definition:</b> <a href="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_a08c4f1d4e19627689e141cf08b9f77bc"><div class="ttname"><a href="namespaceoperations__research.html#a08c4f1d4e19627689e141cf08b9f77bc">operations_research::ComputeMinimumWeightMatching</a></div><div class="ttdeci">absl::StatusOr&lt; std::vector&lt; std::pair&lt; typename GraphType::NodeIndex, typename GraphType::NodeIndex &gt; &gt; &gt; ComputeMinimumWeightMatching(const GraphType &amp;graph, const WeightFunctionType &amp;weight)</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00109">christofides.h:109</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_a111f44b9b9cf67a8e8d83794ac9f5291"><div class="ttname"><a href="namespaceoperations__research.html#a111f44b9b9cf67a8e8d83794ac9f5291">operations_research::CapAdd</a></div><div class="ttdeci">int64_t CapAdd(int64_t x, int64_t y)</div><div class="ttdef"><b>Definition:</b> <a href="saturated__arithmetic_8h_source.html#l00126">saturated_arithmetic.h:126</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_a33a2f4c26fd60cd0fa98257b571c974f"><div class="ttname"><a href="namespaceoperations__research.html#a33a2f4c26fd60cd0fa98257b571c974f">operations_research::BuildPrimMinimumSpanningTree</a></div><div class="ttdeci">std::vector&lt; typename Graph::ArcIndex &gt; BuildPrimMinimumSpanningTree(const Graph &amp;graph, const ArcValue &amp;arc_value)</div><div class="ttdef"><b>Definition:</b> <a href="minimum__spanning__tree_8h_source.html#l00115">minimum_spanning_tree.h:115</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_a7ae31ba4c3b4899478e53ca13df35dfc"><div class="ttname"><a href="namespaceoperations__research.html#a7ae31ba4c3b4899478e53ca13df35dfc">operations_research::NodeIndex</a></div><div class="ttdeci">int32_t NodeIndex</div><div class="ttdef"><b>Definition:</b> <a href="ebert__graph_8h_source.html#l00200">ebert_graph.h:192</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_a93c78280670aaeea4913d156699a403a"><div class="ttname"><a href="namespaceoperations__research.html#a93c78280670aaeea4913d156699a403a">operations_research::ComputeMinimumWeightMatchingWithMIP</a></div><div class="ttdeci">absl::StatusOr&lt; std::vector&lt; std::pair&lt; typename GraphType::NodeIndex, typename GraphType::NodeIndex &gt; &gt; &gt; ComputeMinimumWeightMatchingWithMIP(const GraphType &amp;graph, const WeightFunctionType &amp;weight)</div><div class="ttdef"><b>Definition:</b> <a href="christofides_8h_source.html#l00145">christofides.h:145</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_aa63055860fc53f8eed56d23d2571c180"><div class="ttname"><a href="namespaceoperations__research.html#aa63055860fc53f8eed56d23d2571c180">operations_research::BuildEulerianTourFromNode</a></div><div class="ttdeci">std::vector&lt; NodeIndex &gt; BuildEulerianTourFromNode(const Graph &amp;graph, NodeIndex root)</div><div class="ttdef"><b>Definition:</b> <a href="eulerian__path_8h_source.html#l00116">eulerian_path.h:116</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_ab1cf773de0cae72d0c44efe5b8f4bb89"><div class="ttname"><a href="namespaceoperations__research.html#ab1cf773de0cae72d0c44efe5b8f4bb89">operations_research::IsEulerianGraph</a></div><div class="ttdeci">bool IsEulerianGraph(const Graph &amp;graph)</div><div class="ttdef"><b>Definition:</b> <a href="eulerian__path_8h_source.html#l00040">eulerian_path.h:40</a></div></div>
<div class="ttc" id="anamespaceoperations__research_html_aecf320bda6e95d1edaf3a546673e3e6b"><div class="ttname"><a href="namespaceoperations__research.html#aecf320bda6e95d1edaf3a546673e3e6b">operations_research::ArcIndex</a></div><div class="ttdeci">int32_t ArcIndex</div><div class="ttdef"><b>Definition:</b> <a href="ebert__graph_8h_source.html#l00201">ebert_graph.h:201</a></div></div>
<div class="ttc" id="apack_8cc_html_a4255f714cea26cdd64f6a0ee72d34a8c"><div class="ttname"><a href="pack_8cc.html#a4255f714cea26cdd64f6a0ee72d34a8c">weight</a></div><div class="ttdeci">int64_t weight</div><div class="ttdef"><b>Definition:</b> <a href="pack_8cc_source.html#l00510">pack.cc:510</a></div></div>
<div class="ttc" id="aperfect__matching_8h_html"><div class="ttname"><a href="perfect__matching_8h.html">perfect_matching.h</a></div></div>
<div class="ttc" id="arouting__flow_8cc_html_a64e7efc5529154ba56903e75f5300990"><div class="ttname"><a href="routing__flow_8cc.html#a64e7efc5529154ba56903e75f5300990">tail</a></div><div class="ttdeci">int64_t tail</div><div class="ttdef"><b>Definition:</b> <a href="routing__flow_8cc_source.html#l00149">routing_flow.cc:149</a></div></div>
<div class="ttc" id="arouting__flow_8cc_html_afca32f65388659a4b0956496169488b4"><div class="ttname"><a href="routing__flow_8cc.html#afca32f65388659a4b0956496169488b4">head</a></div><div class="ttdeci">int64_t head</div><div class="ttdef"><b>Definition:</b> <a href="routing__flow_8cc_source.html#l00150">routing_flow.cc:150</a></div></div>
<div class="ttc" id="asaturated__arithmetic_8h_html"><div class="ttname"><a href="saturated__arithmetic_8h.html">saturated_arithmetic.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.18-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_a7cc1eeded8f693d0da6c729bc88c45a.html">ortools</a></li><li class="navelem"><a class="el" href="dir_725f3a5915051842f84e3ea508be2a62.html">graph</a></li><li class="navelem"><a class="el" href="christofides_8h.html">christofides.h</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
</ul>
</div>
</body>
</html>