geos::operation::cluster::UnionFind Class Reference

`#include <UnionFind.h>`

## Public Member Functions

| UnionFind (size_t n)
bool | same (size_t i, size_t j)
bool | different (size_t i, size_t j)
size_t | find (size_t i)
void | join (size_t i, size_t j)
size_t | getNumClusters () const
template<typename T>
void | sortByCluster (T begin, T end)
Clusters | getClusters ()
Clusters | getClusters (std::vector< size_t > elems)

## Detailed Description

UnionFind provides an implementation of a disjoint set data structure that is useful in clustering. Elements to be clustered are referred to according to a numeric index.

## Constructor & Destructor Documentation

## UnionFind()

geos::operation::cluster::UnionFind::UnionFind | ( | size_t | n | ) |

inline explicit

Create a UnionFind object

Parameters

  n | the number of elements to be clustered (fixed size)

## Member Function Documentation

## find()

size_t geos::operation::cluster::UnionFind::find | ( | size_t | i | ) |

inline

Return the ID of the cluster associated with an item

Parameters

  i | index of the item to lookup

Returns
  a numeric cluster ID

Referenced by join().

## getClusters() [1/2]

Clusters geos::operation::cluster::UnionFind::getClusters | ( |  | ) |

Return the clusters associated with all elements

Returns
  an object that allows iteration over the elements of each cluster

## getClusters() [2/2]

Clusters geos::operation::cluster::UnionFind::getClusters | ( | std::vector< size_t > | elems | ) |

Return the clusters associated with the given elements

Parameters

  elems | a vector of element ids

Returns
  an object that allows iteration over the elements of each cluster

## join()

void geos::operation::cluster::UnionFind::join | ( | size_t | i,
|  | size_t | j )

inline

Merge the clusters associated with two items

Parameters

  i | ID of an item associated with the first cluster
  j | ID of an item associated with the second cluster

References find().

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

- UnionFind.h