<trclass="memdesc:a93b2c753675c77bfdbc0c33eb582380b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Adds a node in the graph. <ahref="#a93b2c753675c77bfdbc0c33eb582380b">More...</a><br/></td></tr>
<trclass="memitem:a77a24beaed190e2f3a0d12662a65b18a"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="classConnectedComponentsFinder.html#a77a24beaed190e2f3a0d12662a65b18a">AddEdge</a> (T node1, T node2)</td></tr>
<trclass="memdesc:a77a24beaed190e2f3a0d12662a65b18a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Adds an edge in the graph. <ahref="#a77a24beaed190e2f3a0d12662a65b18a">More...</a><br/></td></tr>
<trclass="memitem:a67dc34888511ab5b90b7389c90dbc1f8"><tdclass="memItemLeft"align="right"valign="top">bool </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="classConnectedComponentsFinder.html#a67dc34888511ab5b90b7389c90dbc1f8">Connected</a> (T node1, T node2)</td></tr>
<trclass="memdesc:a67dc34888511ab5b90b7389c90dbc1f8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns true iff both nodes are in the same connected component. <ahref="#a67dc34888511ab5b90b7389c90dbc1f8">More...</a><br/></td></tr>
<trclass="memdesc:a7a173636e3dce11a27f2f7121e01a563"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Finds the connected component containing a node, and returns the total number of nodes in that component. <ahref="#a7a173636e3dce11a27f2f7121e01a563">More...</a><br/></td></tr>
<trclass="memitem:a9eaa06cffceda90c1d44f550ad3459f3"><tdclass="memItemLeft"align="right"valign="top">std::vector< std::vector< T >> </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="classConnectedComponentsFinder.html#a9eaa06cffceda90c1d44f550ad3459f3">FindConnectedComponents</a> ()</td></tr>
<trclass="memdesc:a9eaa06cffceda90c1d44f550ad3459f3"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Finds all the connected components and assigns them to components. <ahref="#a9eaa06cffceda90c1d44f550ad3459f3">More...</a><br/></td></tr>
<trclass="memdesc:a30350bb98f0e1f7ae47ec1292d253b52"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the current number of connected components. <ahref="#a30350bb98f0e1f7ae47ec1292d253b52">More...</a><br/></td></tr>
<trclass="memdesc:a350a0a0790e558f619478ce97c8f2ae7"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the current number of added distinct nodes. <ahref="#a350a0a0790e558f619478ce97c8f2ae7">More...</a><br/></td></tr>
<p>repeating, adding nodes and edges as needed. Adding an edge will automatically also add the two nodes at its ends, if they haven't already been added. std::vector<std::set<MyNodeType>> components; cc.FindConnectedComponents(&components); Each entry in components now contains all the nodes in a single connected component.</p>
<p>Usage with flat_hash_set: using ConnectedComponentType = flat_hash_set<MyNodeType>; <aclass="el"href="classConnectedComponentsFinder.html"title="Usage: ConnectedComponentsFinder<MyNodeType> cc; cc.AddNode(node1); cc.AddNode(node2); cc....">ConnectedComponentsFinder</a><ConnectedComponentType::key_type, ConnectedComponentType::hasher> cc; ... std::vector<ConnectedComponentType> components; cc.FindConnectedComponents(&components);</p>
<p>If you want to, you can continue adding nodes and edges after calling FindConnectedComponents, then call it again later.</p>
<p>If your node type isn't STL-friendly, then you can use pointers to it instead: ConnectedComponentsFinder<MySTLUnfriendlyNodeType*> cc; cc.AddNode(&node1); ... and so on... Of course, in this usage, the connected components finder retains these pointers through its lifetime (though it doesn't dereference them). </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00189">189</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
</div><h2class="groupheader">Constructor & Destructor Documentation</h2>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00192">192</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Also adds both endpoint nodes as necessary. It is not an error to add the same edge twice. Self-edges are OK too. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00204">204</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>It is OK to add the same node more than once; additions after the first have no effect. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00200">200</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Returns true iff both nodes are in the same connected component. </p>
<p>Returns false if either node has not been already added with AddNode. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00211">211</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Finds all the connected components and assigns them to components. </p>
<p>Components are ordered in the same way nodes were added, i.e. if node 'b' was added before node 'c', then either:</p><ul>
<li>'c' belongs to the same component as a node 'a' added before 'b', or</li>
<li>the component for 'c' comes after the one for 'b'. There are two versions:</li>
<li>The first one returns the result, and stores each component in a vector. This is the preferred version.</li>
<li>The second one populates the result, and stores each component in a set. </li>
</ul>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00232">232</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00240">240</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Returns the current number of connected components. </p>
<p>This number can change as the new nodes or edges are added. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00253">253</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Returns the current number of added distinct nodes. </p>
<p>This includes nodes added explicitly via the calls to <aclass="el"href="classConnectedComponentsFinder.html#a93b2c753675c77bfdbc0c33eb582380b"title="Adds a node in the graph.">AddNode()</a> method and implicitly via the calls to <aclass="el"href="classConnectedComponentsFinder.html#a77a24beaed190e2f3a0d12662a65b18a"title="Adds an edge in the graph.">AddEdge()</a> method. Nodes that were added several times only count once. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00261">261</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>
<p>Finds the connected component containing a node, and returns the total number of nodes in that component. </p>
<p>Returns zero iff the node has not been already added with AddNode. </p>
<pclass="definition">Definition at line <aclass="el"href="connected__components_8h_source.html#l00219">219</a> of file <aclass="el"href="connected__components_8h_source.html">connected_components.h</a>.</p>