COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
DisjSets Class Reference

#include <DisjSets.h>

Public Member Functions

 DisjSets (int numElements)
 
int find (int x) const
 
int find (int x)
 
void unionSets (int root1, int root2)
 

Detailed Description

Disjoint set class. Use union by rank and path compression. Elements in the set are numbered starting at 0.

Definition at line 22 of file DisjSets.h.

Constructor & Destructor Documentation

◆ DisjSets()

DisjSets::DisjSets ( int  numElements)
explicit

Construct the disjoint sets object. numElements is the initial number of disjoint sets.

Definition at line 7 of file DisjSets.cpp.

Member Function Documentation

◆ find() [1/2]

int DisjSets::find ( int  x)

Perform a find with path compression. Error checks omitted again for simplicity. Return the set containing x.

Definition at line 50 of file DisjSets.cpp.

◆ find() [2/2]

int DisjSets::find ( int  x) const

Perform a find. Error checks omitted again for simplicity. Return the set containing x.

Definition at line 36 of file DisjSets.cpp.

◆ unionSets()

void DisjSets::unionSets ( int  root1,
int  root2 
)

Union two disjoint sets. For simplicity, we assume root1 and root2 are distinct and represent set names. root1 is the root of set 1. root2 is the root of set 2.

Definition at line 18 of file DisjSets.cpp.


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