NOTE(user): The rest of the functions below should also be in namespace util, but for historical reasons it hasn't been done yet.
A connected components finder that only works on dense ints.
Definition at line 81 of file connected_components.h.
Public Member Functions | |
| DenseConnectedComponentsFinder () | |
| DenseConnectedComponentsFinder (const DenseConnectedComponentsFinder &)=delete | |
| DenseConnectedComponentsFinder & | operator= (const DenseConnectedComponentsFinder &)=delete |
| void | AddEdge (int node1, int node2) |
| The main API is the same as ConnectedComponentsFinder (below): see the homonymous functions there. More... | |
| bool | Connected (int node1, int node2) |
| int | GetSize (int node) |
| int | GetNumberOfComponents () const |
| int | GetNumberOfNodes () const |
| void | SetNumberOfNodes (int num_nodes) |
| Sets the number of nodes in the graph. More... | |
| int | FindRoot (int node) |
| Returns the root of the set for the given node. More... | |
| std::vector< int > | GetComponentIds () |
| Returns the same as GetConnectedComponents(). More... | |
|
inline |
Definition at line 83 of file connected_components.h.
|
delete |
| void DenseConnectedComponentsFinder::AddEdge | ( | int | node1, |
| int | node2 | ||
| ) |
The main API is the same as ConnectedComponentsFinder (below): see the homonymous functions there.
| bool DenseConnectedComponentsFinder::Connected | ( | int | node1, |
| int | node2 | ||
| ) |
| int DenseConnectedComponentsFinder::FindRoot | ( | int | node | ) |
Returns the root of the set for the given node.
node must be in [0;GetNumberOfNodes()-1]. Non-const because it does path compression internally.
| std::vector<int> DenseConnectedComponentsFinder::GetComponentIds | ( | ) |
Returns the same as GetConnectedComponents().
|
inline |
Definition at line 95 of file connected_components.h.
|
inline |
Definition at line 96 of file connected_components.h.
| int DenseConnectedComponentsFinder::GetSize | ( | int | node | ) |
|
delete |
| void DenseConnectedComponentsFinder::SetNumberOfNodes | ( | int | num_nodes | ) |
Sets the number of nodes in the graph.
The graph can only grow: this dies if "num_nodes" is lower or equal to any of the values ever given to AddEdge(), or lower than a previous value given to SetNumberOfNodes(). You need this if there are nodes that don't have any edges.