10 Union-Find: Sets with only Canonical Elements
(require data/union-find) | package: data-lib |
The union-find algorithm and data structure provides an API for representing sets that contain a single, canonical element. The sets support an (imperative) union operation (the library picks one of the canonical elements of the original sets to be the canonical element of the union), as well as getting and setting the canonical element.
These operations are not thread-safe.
This is a constant time operation.
Examples: | ||||
|
This is a constant time operation.
Examples: | ||||
|
This is an amortized (essentially) constant time operation.
Example: | ||
|
This is an amortized (essentially) constant time operation.
Examples: | |||||||||||||
|
procedure
(uf-same-set? a b) → boolean?
a : uf-set? b : uf-set?
This is an amortized (essentially) constant time operation.
Examples: | |||||||||||||
|
procedure
(uf-set-canonical! a c) → void?
a : uf-set? c : any/c
This is an amortized (essentially) constant time operation.
Examples: | |||||||||||||||||||
|