---
name: "mlpack_emst_UnionFind"
section: "3"
platform: "linux"
package: "mlpack-doc"
version: "1.0.10-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/mlpack_emst_UnionFind"
---

# mlpack\_emst\_UnionFind(3)

A Union-Find data structure.

## NAME

mlpack::emst::UnionFind -

A Union-Find data structure.

## SYNOPSIS

### 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.*  void **Union** (const size\_t x, const size\_t y)\
 *Union the components containing x and y.*

### Private Attributes

arma::Col\< size\_t \> **parent**\
 arma::ivec **rank**\

## 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 40 of file union\_find.hpp.

## Constructor & Destructor Documentation

### mlpack::emst::UnionFind::UnionFind (const size\_tsize)` [inline]`

Construct the object with the given size.

Definition at line 48 of file union\_find.hpp.

References parent, and rank.

### mlpack::emst::UnionFind::~UnionFind ()` [inline]`

Destroy the object (nothing to do).

Definition at line 58 of file union\_find.hpp.

## Member Function Documentation

### size\_t mlpack::emst::UnionFind::Find (const size\_tx)` [inline]`

Returns the component containing an element.

**Parameters:**

*x* the component to be found

**Returns:**

The index of the component containing x

Definition at line 66 of file union\_find.hpp.

References parent.

Referenced by Union().

### void mlpack::emst::UnionFind::Union (const size\_tx, const size\_ty)` [inline]`

Union the components containing x and y.

**Parameters:**

*x* one component \
 *y* the other component

Definition at line 86 of file union\_find.hpp.

References Find(), parent, and rank.

## Member Data Documentation

### arma::Col\<size\_t\> mlpack::emst::UnionFind::parent` [private]`

Definition at line 43 of file union\_find.hpp.

Referenced by Find(), Union(), and UnionFind().

### arma::ivec mlpack::emst::UnionFind::rank` [private]`

Definition at line 44 of file union\_find.hpp.

Referenced by Union(), and UnionFind().

## Author

Generated automatically by Doxygen for MLPACK from the source code.
