Skip to main content

Crate union_find

Crate union_find 

Source
Expand description

Generic Union-Find (Disjoint Set) data structure.

Each component carries:

  • a size (used for union-by-size),
  • a character value (an arbitrary usize updated through the user-supplied op closure).

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ยง

UnionFind
Generic Union-Find with weighted union and per-component character.