ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
UnionFind.h

The MFSET of section 10.2 engineered, beyond the book. More...

Files

file  ADS/mfset/UnionFind.h
 The MFSET of section 10.2 engineered, beyond the book [see MFSet.h]: the forest of the parents in one vector of integers, where a root keeps minus the size of its tree instead of a parent, so that the union by size needs no second vector and a find() touches one array; find() halves the path (every other node on the way is made a child of its grandparent), which needs a single pass, no recursion and no stack, and keeps the bound of the compression with the union by size (Tarjan and van Leeuwen): a sequence of \( m \geq n \) operations on \( n \) elements takes.

Classes

class  ADS::DisjointSets< L, C, Policy >
 the union of disjoint sets of \( [ 0 , n ) \), the roots joined by L, the paths shortened by C, the links of the roots told through Policy More...

Typedefs

using ADS::UnionFind = DisjointSets<>
 the union by size with path halving

Enumerations

enum class  ADS::Union { ADS::Union::SIZE , ADS::Union::RANK }
 how the roots of two trees are joined: the smaller tree under the root of the larger, or the lower rank under the higher More...
enum class  ADS::Compression { ADS::Compression::HALVING , ADS::Compression::FULL }
 how find() shortens the path: halving it (every other node on the way made a child of its grandparent, one pass), or compressing it (all the nodes on the way made children of the root, two passes) More...

Detailed description

The MFSET of section 10.2 engineered, beyond the book.

The definitions, the invariants and the costs of the area are in Theory of merge-find sets.

Typedef documentation

◆ UnionFind

the union by size with path halving

Enumeration type documentation

◆ Compression

enum class ADS::Compression
strong

how find() shortens the path: halving it (every other node on the way made a child of its grandparent, one pass), or compressing it (all the nodes on the way made children of the root, two passes)

Enumerator
HALVING 

half the path under grandparents

FULL 

each node under the root

◆ Union

enum class ADS::Union
strong

how the roots of two trees are joined: the smaller tree under the root of the larger, or the lower rank under the higher

Enumerator
SIZE 

the smaller tree under the root of the larger

RANK 

the lower rank under the higher