DenseConnectedComponentsFinder Class Reference

Detailed Description

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
 
DenseConnectedComponentsFinderoperator= (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...
 

Constructor & Destructor Documentation

◆ DenseConnectedComponentsFinder() [1/2]

DenseConnectedComponentsFinder::DenseConnectedComponentsFinder ( )
inline

Definition at line 83 of file connected_components.h.

◆ DenseConnectedComponentsFinder() [2/2]

DenseConnectedComponentsFinder::DenseConnectedComponentsFinder ( const DenseConnectedComponentsFinder )
delete

Member Function Documentation

◆ AddEdge()

void DenseConnectedComponentsFinder::AddEdge ( int  node1,
int  node2 
)

The main API is the same as ConnectedComponentsFinder (below): see the homonymous functions there.

◆ Connected()

bool DenseConnectedComponentsFinder::Connected ( int  node1,
int  node2 
)

◆ FindRoot()

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.

◆ GetComponentIds()

std::vector<int> DenseConnectedComponentsFinder::GetComponentIds ( )

Returns the same as GetConnectedComponents().

◆ GetNumberOfComponents()

int DenseConnectedComponentsFinder::GetNumberOfComponents ( ) const
inline

Definition at line 95 of file connected_components.h.

◆ GetNumberOfNodes()

int DenseConnectedComponentsFinder::GetNumberOfNodes ( ) const
inline

Definition at line 96 of file connected_components.h.

◆ GetSize()

int DenseConnectedComponentsFinder::GetSize ( int  node)

◆ operator=()

DenseConnectedComponentsFinder& DenseConnectedComponentsFinder::operator= ( const DenseConnectedComponentsFinder )
delete

◆ SetNumberOfNodes()

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.


The documentation for this class was generated from the following file: