<ahref="connected__components_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">//</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00026"
<divclass="ttc"id="classConnectedComponentsFinder_html_a93b2c753675c77bfdbc0c33eb582380b"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a93b2c753675c77bfdbc0c33eb582380b">ConnectedComponentsFinder::AddNode</a></div><divclass="ttdeci">void AddNode(T node)</div><divclass="ttdoc">Adds a node in the graph.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00200">connected_components.h:200</a></div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_a071f52956431e211e14ed7f3894c1d0b"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#a071f52956431e211e14ed7f3894c1d0b">DenseConnectedComponentsFinder::Connected</a></div><divclass="ttdeci">bool Connected(int node1, int node2)</div></div>
<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="classConnectedComponentsFinder_html_aa669a113d3ee23c506b97949f740b1cc"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#aa669a113d3ee23c506b97949f740b1cc">ConnectedComponentsFinder::ConnectedComponentsFinder</a></div><divclass="ttdeci">ConnectedComponentsFinder()</div><divclass="ttdoc">Constructs a connected components finder.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00192">connected_components.h:192</a></div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a7a173636e3dce11a27f2f7121e01a563"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a7a173636e3dce11a27f2f7121e01a563">ConnectedComponentsFinder::GetSize</a></div><divclass="ttdeci">int GetSize(T node)</div><divclass="ttdoc">Finds the connected component containing a node, and returns the total number of nodes in that compon...</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00219">connected_components.h:219</a></div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_a46780e194c525fa9853fa899d69b4340"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#a46780e194c525fa9853fa899d69b4340">DenseConnectedComponentsFinder::SetNumberOfNodes</a></div><divclass="ttdeci">void SetNumberOfNodes(int num_nodes)</div><divclass="ttdoc">Sets the number of nodes in the graph.</div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a9eaa06cffceda90c1d44f550ad3459f3"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a9eaa06cffceda90c1d44f550ad3459f3">ConnectedComponentsFinder::FindConnectedComponents</a></div><divclass="ttdeci">std::vector< std::vector< T >> FindConnectedComponents()</div><divclass="ttdoc">Finds all the connected components and assigns them to components.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00232">connected_components.h:232</a></div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html">DenseConnectedComponentsFinder</a></div><divclass="ttdoc">NOTE(user): The rest of the functions below should also be in namespace util, but for historical reas...</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00081">connected_components.h:81</a></div></div>
<divclass="ttc"id="namespaceutil_html_a13f0e8f7e15873600cf8e395958c71e1"><divclass="ttname"><ahref="namespaceutil.html#a13f0e8f7e15873600cf8e395958c71e1">util::GetConnectedComponents</a></div><divclass="ttdeci">std::vector< int > GetConnectedComponents(int num_nodes, const UndirectedGraph &graph)</div><divclass="ttdoc">Finds the connected components of the graph, using BFS internally.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00289">connected_components.h:289</a></div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a350a0a0790e558f619478ce97c8f2ae7"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a350a0a0790e558f619478ce97c8f2ae7">ConnectedComponentsFinder::GetNumberOfNodes</a></div><divclass="ttdeci">int GetNumberOfNodes() const</div><divclass="ttdoc">Returns the current number of added distinct nodes.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00261">connected_components.h:261</a></div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a67dc34888511ab5b90b7389c90dbc1f8"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a67dc34888511ab5b90b7389c90dbc1f8">ConnectedComponentsFinder::Connected</a></div><divclass="ttdeci">bool Connected(T node1, T node2)</div><divclass="ttdoc">Returns true iff both nodes are in the same connected component.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00211">connected_components.h:211</a></div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a30350bb98f0e1f7ae47ec1292d253b52"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a30350bb98f0e1f7ae47ec1292d253b52">ConnectedComponentsFinder::GetNumberOfComponents</a></div><divclass="ttdeci">int GetNumberOfComponents() const</div><divclass="ttdoc">Returns the current number of connected components.</div><divclass="ttdef"><b>Definition:</b><ahref="connected__components_8h_source.html#l00253">connected_components.h:253</a></div></div>
<divclass="ttc"id="classConnectedComponentsFinder_html_a21da7363443c34ad00c529fae4b3b3e2"><divclass="ttname"><ahref="classConnectedComponentsFinder.html#a21da7363443c34ad00c529fae4b3b3e2">ConnectedComponentsFinder::operator=</a></div><divclass="ttdeci">ConnectedComponentsFinder & operator=(const ConnectedComponentsFinder &)=delete</div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_aee7f0057f42256a520b5ef32bae58b36"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#aee7f0057f42256a520b5ef32bae58b36">DenseConnectedComponentsFinder::GetComponentIds</a></div><divclass="ttdeci">std::vector< int > GetComponentIds()</div><divclass="ttdoc">Returns the same as GetConnectedComponents().</div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_a20f2a5d6bb7631a0dcdd678387a1b61a"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#a20f2a5d6bb7631a0dcdd678387a1b61a">DenseConnectedComponentsFinder::operator=</a></div><divclass="ttdeci">DenseConnectedComponentsFinder & operator=(const DenseConnectedComponentsFinder &)=delete</div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_aba450cf3f16d9386d043c4354a19a4aa"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#aba450cf3f16d9386d043c4354a19a4aa">DenseConnectedComponentsFinder::AddEdge</a></div><divclass="ttdeci">void AddEdge(int node1, int node2)</div><divclass="ttdoc">The main API is the same as ConnectedComponentsFinder (below): see the homonymous functions there.</div></div>
<divclass="ttc"id="classDenseConnectedComponentsFinder_html_afdcff89dd2374ce33c05934d328e64ec"><divclass="ttname"><ahref="classDenseConnectedComponentsFinder.html#afdcff89dd2374ce33c05934d328e64ec">DenseConnectedComponentsFinder::FindRoot</a></div><divclass="ttdeci">int FindRoot(int node)</div><divclass="ttdoc">Returns the root of the set for the given node.</div></div>