Expand description
Generic Union-Find (Disjoint Set) data structure.
Each component carries:
- a
size(used for union-by-size), - a
charactervalue (an arbitraryusizeupdated through the user-suppliedopclosure).
union(x, y, w) merges the components of x and y, applying the closure
op to combine their characters along with the edge weight w. When x and
y are already in the same component, only character[root] = op(character[root], w)
is updated and the function returns false; otherwise it returns true.
Structsยง
- Union
Find - Generic Union-Find with weighted union and per-component character.