mlpack
|
A Union-Find data structure. More...
#include <union_find.hpp>
Public Member Functions | |
UnionFind (const size_t size) | |
Construct the object with the given size. | |
~UnionFind () | |
Destroy the object (nothing to do). | |
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... | |
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.
|
inline |
Returns the component containing an element.
x | the component to be found |
|
inline |
Union the components containing x and y.
x | one component |
y | the other component |