UnionFind Class Reference

A Union-Find data structure. More...

Public Member Functions

 UnionFind (const size_t size)
 Construct the object with the given size. More...

 
 ~UnionFind ()
 Destroy the object (nothing to do). More...

 
size_t Find (const size_t x)
 Returns the component containing an element. More...

 
void Union (const size_t x, const size_t y)
 Union the components containing x and y. More...

 

Detailed Description

A Union-Find data structure.

See Cormen, Rivest, & Stein for details. The structure tracks the components of a graph. Each point in the graph is initially in its own component. Calling Union(x, y) unites the components indexed by x and y. Find(x) returns the index of the component containing point x.

Definition at line 30 of file union_find.hpp.

Constructor & Destructor Documentation

◆ UnionFind()

UnionFind ( const size_t  size)
inline

Construct the object with the given size.

Definition at line 38 of file union_find.hpp.

◆ ~UnionFind()

~UnionFind ( )
inline

Destroy the object (nothing to do).

Definition at line 48 of file union_find.hpp.

Member Function Documentation

◆ Find()

size_t Find ( const size_t  x)
inline

Returns the component containing an element.

Parameters
xthe component to be found
Returns
The index of the component containing x

Definition at line 56 of file union_find.hpp.

Referenced by UnionFind::Union().

◆ Union()

void Union ( const size_t  x,
const size_t  y 
)
inline

Union the components containing x and y.

Parameters
xone component
ythe other component

Definition at line 76 of file union_find.hpp.

References UnionFind::Find().


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/emst/union_find.hpp