UnionFind
UnionFind is a data structure to manipulate disjoint-set. Complexity of operations is O(α(n)) (inverse Ackermann function) amortized.
Usage
uf = UnionFind.new(6)
uf = uf |> UnionFind.unite(1, 4)
UnionFind.same?(uf, 1, 4) # => true
UnionFind.same?(uf, 1, 2) # => false
UnionFind.size(uf, 1) # => 2
UnionFind.size(uf, 5) # => 1Installation
If available in Hex, the package can be installed
by adding union_find to your list of dependencies in mix.exs:
def deps do
[
{:union_find, "~> 0.1.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/union_find.