package unionFind
Install
Dune Dependency
Authors
Maintainers
Sources
md5=3311141704584930d9e7358ef0edf2f4
sha512=116dfd8078f697012f8b53f518d6e05fca09b1d57b7ce7724b0789bf6d2ecacc7efa462a6bbcdf486358ce17e84f5d106a7e799d9b44cbc0755e433fdd82b724
doc/unionFind/UnionFind/index.html
Module UnionFind
Source
This module offers a union-find data structure based on disjoint set forests, with path compression and linking by rank.
A type of elements, also known as references.
Operations for creating a new reference, reading and writing a reference, and testing whether two references are equivalent. (Two references are considered equivalent after they have been merged by union
.)
union x y
does nothing if the references x
and y
are equal, and merges them if they are distinct. In the latter case, the content of the merged reference is arbitrarily chosen to be the previous content of x
or y
.
find x
returns the representative element of x
's equivalence class.
Instead of hard-coding the use of mutable state, we parameterize the module over an implementation S
of stores, as described by the signature STORE
. This allows the client to choose between many different representations of the store: e.g., based on primitive references, based on a (possibly extensible) primitive array, based on a persistent map, based on a persistent or semi-persistent array, based on transactional references, etc.
The signature provided by this module is also STORE
, extended with an operation for merging two references.
This module offers an implementation of STORE
based on immutable integer maps. The stores thus obtained are persistent.
This module offers an implementation of STORE
based on mutable references.
This module offers an implementation of STORE
based on a simple form of mutable transactional references.
This module offers an implementation of STORE
based on a single mutable extensible array.