PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
|
Disjoint Set Union-Find data structure. More...
#include <DisjointSetUnionFind.h>
Public Types | |
using | IndexType = TIndex |
Index type used in the disjoint set union-find structure. | |
Public Member Functions | |
DisjointSetUnionFind (IndexType n) | |
Construct a new Disjoint Set Union-Find object. | |
void | Prepare (IndexType n) |
Reserve memory for n vertices and reset the structure. | |
IndexType | Find (IndexType u) |
Find the root of the set containing vertex u | |
IndexType | Union (IndexType u, IndexType v) |
Merge the sets containing vertices u and v | |
IndexType | Root (IndexType u) const |
Find the root of the set containing vertex u without path compression. | |
IndexType | Size (IndexType u) const |
Find the size of the set containing vertex u | |
IndexType | NumVertices () const |
Get the number of vertices in the disjoint set union-find structure. | |
Disjoint Set Union-Find data structure.
TIndex | Index type used in the disjoint set union-find structure. |
This class implements a disjoint set union-find data structure with path compression and union by rank. It is used to efficiently manage and merge disjoint sets, which is useful in various graph algorithms.
pbat::graph::DisjointSetUnionFind< TIndex >::DisjointSetUnionFind | ( | IndexType | n | ) |
Construct a new Disjoint Set Union-Find object.
n | Number of vertices |
TIndex pbat::graph::DisjointSetUnionFind< TIndex >::Find | ( | IndexType | u | ) |
Find the root of the set containing vertex u
u | Vertex index |
u
TIndex pbat::graph::DisjointSetUnionFind< TIndex >::NumVertices | ( | ) | const |
Get the number of vertices in the disjoint set union-find structure.
void pbat::graph::DisjointSetUnionFind< TIndex >::Prepare | ( | IndexType | n | ) |
Reserve memory for n
vertices and reset the structure.
n | Number of vertices |
|
inline |
Find the root of the set containing vertex u
without path compression.
u | Vertex index |
u
TIndex pbat::graph::DisjointSetUnionFind< TIndex >::Size | ( | IndexType | u | ) | const |
Find the size of the set containing vertex u
u | Vertex index |
u
TIndex pbat::graph::DisjointSetUnionFind< TIndex >::Union | ( | IndexType | u, |
IndexType | v ) |
Merge the sets containing vertices u
and v
u | Vertex index of the first set |
v | Vertex index of the second set |