<ahref="io_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div><divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> </div><divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment">// A collections of i/o utilities for the Graph classes in ./graph.h.</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> </div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="preprocessor">#ifndef UTIL_GRAPH_IO_H_</span></div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="preprocessor">#define UTIL_GRAPH_IO_H_</span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> </div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="preprocessor">#include <algorithm></span></div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="preprocessor">#include <memory></span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> <spanclass="preprocessor">#include <numeric></span></div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="preprocessor">#include <string></span></div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="preprocessor">#include <vector></span></div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> </div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="preprocessor">#include "absl/strings/numbers.h"</span></div><divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="preprocessor">#include "absl/strings/str_cat.h"</span></div><divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="preprocessor">#include "absl/strings/str_format.h"</span></div><divclass="line"><aname="l00028"></a><spanclass="lineno">
<divclass="ttc"id="namespaceutil_html"><divclass="ttname"><ahref="namespaceutil.html">util</a></div><divclass="ttdoc">Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00056">connected_components.h:56</a></div></div>
<divclass="ttc"id="namespaceutil_html_ae76339cb2dcd3bc05ad762146f91fdda"><divclass="ttname"><ahref="namespaceutil.html#ae76339cb2dcd3bc05ad762146f91fdda">util::Graph</a></div><divclass="ttdeci">ListGraph Graph</div><divclass="ttdoc">Defining the simplest Graph interface as Graph for convenience.</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l02358">graph.h:2358</a></div></div>
<divclass="ttc"id="classutil_1_1BaseGraph_html_a0f551c921fa0b5aaa334a6e36f61db4a"><divclass="ttname"><ahref="classutil_1_1BaseGraph.html#a0f551c921fa0b5aaa334a6e36f61db4a">util::BaseGraph::num_nodes</a></div><divclass="ttdeci">NodeIndexType num_nodes() const</div><divclass="ttdoc">Returns the number of valid nodes in the graph.</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l00201">graph.h:201</a></div></div>
<divclass="ttc"id="namespaceutil_html_affed79554a202aaa8bda5b5e98c3a6b2"><divclass="ttname"><ahref="namespaceutil.html#affed79554a202aaa8bda5b5e98c3a6b2">util::GraphToString</a></div><divclass="ttdeci">std::string GraphToString(const Graph &graph, GraphToStringFormat format)</div><divclass="ttdoc">Implementations of the templated methods.</div><divclass="ttdef"><b>Definition:</b><ahref="io_8h_source.html#l00107">io.h:107</a></div></div>
<divclass="ttc"id="namespaceutil_html_a6600986f328a49c9485aa03fb6c82946"><divclass="ttname"><ahref="namespaceutil.html#a6600986f328a49c9485aa03fb6c82946">util::WriteGraphToFile</a></div><divclass="ttdeci">util::Status WriteGraphToFile(const Graph &graph, const std::string &filename, bool directed, const std::vector< int >&num_nodes_with_color)</div><divclass="ttdoc">Writes a graph to the ".g" file format described above.</div><divclass="ttdef"><b>Definition:</b><ahref="io_8h_source.html#l00223">io.h:223</a></div></div>
<divclass="ttc"id="classutil_1_1ListGraph_html_ab63770fa993b9347586d2852b841bdc2"><divclass="ttname"><ahref="classutil_1_1ListGraph.html#ab63770fa993b9347586d2852b841bdc2">util::ListGraph::OutgoingArcs</a></div><divclass="ttdeci">BeginEndWrapper< OutgoingArcIterator > OutgoingArcs(NodeIndexType node) const</div><divclass="ttdoc">Allows to iterate over the forward arcs that verify Tail(arc) == node.</div></div>
<divclass="ttc"id="classutil_1_1BaseGraph_html_a32ba4a5ca9a4b89f750eb2dc56518b02"><divclass="ttname"><ahref="classutil_1_1BaseGraph.html#a32ba4a5ca9a4b89f750eb2dc56518b02">util::BaseGraph::AllNodes</a></div><divclass="ttdeci">IntegerRange< NodeIndex > AllNodes() const</div><divclass="ttdoc">Allows nice range-based for loop: for (const NodeIndex node : graph.AllNodes()) { ....</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l00929">graph.h:929</a></div></div>
<divclass="ttc"id="classutil_1_1BaseGraph_html_aefb468e4d4a3128c91b3bad9f5b314c8"><divclass="ttname"><ahref="classutil_1_1BaseGraph.html#aefb468e4d4a3128c91b3bad9f5b314c8">util::BaseGraph::num_arcs</a></div><divclass="ttdeci">ArcIndexType num_arcs() const</div><divclass="ttdoc">Returns the number of valid arcs in the graph.</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l00204">graph.h:204</a></div></div>
<divclass="ttc"id="namespaceutil_html_ae705e1342dacc10a13fb3f11f91d0696acac9245da1bf36d1d9382dc579e1a4fd"><divclass="ttname"><ahref="namespaceutil.html#ae705e1342dacc10a13fb3f11f91d0696acac9245da1bf36d1d9382dc579e1a4fd">util::PRINT_GRAPH_ARCS</a></div><divclass="ttdoc">One arc per line, eg. "3->1".</div><divclass="ttdef"><b>Definition:</b><ahref="io_8h_source.html#l00040">io.h:40</a></div></div>
<divclass="ttc"id="classutil_1_1BaseGraph_html_adb271cf4bcf2de5b5bbe300d7054af29"><divclass="ttname"><ahref="classutil_1_1BaseGraph.html#adb271cf4bcf2de5b5bbe300d7054af29">util::BaseGraph< NodeIndexType, ArcIndexType, false >::NodeIndex</a></div><divclass="ttdeci">NodeIndexType NodeIndex</div><divclass="ttdoc">Typedef so you can use Graph::NodeIndex and Graph::ArcIndex to be generic but also to improve the rea...</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l00189">graph.h:189</a></div></div>
<divclass="ttc"id="namespaceutil_html_ae705e1342dacc10a13fb3f11f91d0696aaed5759e3b6e3a8592c9a21e0048b565"><divclass="ttname"><ahref="namespaceutil.html#ae705e1342dacc10a13fb3f11f91d0696aaed5759e3b6e3a8592c9a21e0048b565">util::PRINT_GRAPH_ADJACENCY_LISTS</a></div><divclass="ttdoc">One space-separated adjacency list per line, eg.</div><divclass="ttdef"><b>Definition:</b><ahref="io_8h_source.html#l00044">io.h:44</a></div></div>
<divclass="ttc"id="namespaceutil_html_ae705e1342dacc10a13fb3f11f91d0696a454bb1ede69e280a1e4959acb82748ef"><divclass="ttname"><ahref="namespaceutil.html#ae705e1342dacc10a13fb3f11f91d0696a454bb1ede69e280a1e4959acb82748ef">util::PRINT_GRAPH_ADJACENCY_LISTS_SORTED</a></div><divclass="ttdoc">Ditto, but the adjacency lists are sorted.</div><divclass="ttdef"><b>Definition:</b><ahref="io_8h_source.html#l00047">io.h:47</a></div></div>
<divclass="ttc"id="classutil_1_1ListGraph_html"><divclass="ttname"><ahref="classutil_1_1ListGraph.html">util::ListGraph</a></div><divclass="ttdoc">Basic graph implementation without reverse arc.</div><divclass="ttdef"><b>Definition:</b><ahref="graph_8h_source.html#l00297">graph.h:297</a></div></div>