package unionFind
Install
Dune Dependency
Authors
Maintainers
Sources
md5=3311141704584930d9e7358ef0edf2f4
sha512=116dfd8078f697012f8b53f518d6e05fca09b1d57b7ce7724b0789bf6d2ecacc7efa462a6bbcdf486358ce17e84f5d106a7e799d9b44cbc0755e433fdd82b724
Description
Published: 20 Mar 2020
README
UnionFind: implementations of the union-find data structure
The OCaml library unionFind
offers two implementations of Tarjan's union-find data structure. Both implementations use path compression and linking-by-rank. The direct implementation uses heap-allocated mutable state. The indirect implementation is parameterized over an implementation of the signature STORE
(link), and its operations explicitly take and return a store, so it is possible to use a persistent store, a store-in-an-array, etc.
Installation
To install the latest released version, type opam install unionFind
.
To install from source, clone this repository and type make install
.
Overview of the direct implementation
This implementation (link) offers a type 'a UnionFind.elem
of "elements" and a number of functions that manipulate elements, including UnionFind.make
, UnionFind.union
, UnionFind.find
, and so on.
Overview of the indirect implementation
This implementation (link) offers a functor UnionFind.Make
whose input is an implementation of the signature STORE
(link). Its output is another implementation of the signature STORE
, which in addition to the standard operations on references also offers a union
operation.
A number of implementations of the signature STORE
are provided:
UnionFind.StoreMap
(link) implements a store as an immutable integer map. Thus,UnionFind.Make(UnionFind.StoreMap)
offers a persistent union-find data structure.UnionFind.StoreRef
(link) implements a store in terms of heap-allocated mutable state. There is no compelling reason to useUnionFind.Make(UnionFind.StoreRef)
, because the direct implementationUnionFind
is more efficient.UnionFind.StoreTransactionalRef
(link) implements a mutable store that supports a form of transaction. Thus,UnionFind.Make(UnionFind.StoreTransactionalRef)
offers a union-find data structure that also supports transactions.The higher-order function
UnionFind.StoreTransactionalRef.tentatively
is used to delimit the scope of a transaction.tentatively s f
runs the functionf
within a new transaction on the stores
. Iff
raises an exception, then the transaction is aborted, and any updates performed byf
are rolled back. Otherwise, the updates performed byf
are committed.UnionFind.StoreVector
(link) implements a store as a mutable vector, that is, a mutable extensible array. Thus,UnionFind.Make(UnionFind.StoreVector)
offers an ephemeral union-find data structure, just likeUnionFind.Make(UnionFind.StoreRef)
andUnionFind
.
The documentation is built by make doc
and is then found in the file _build/default/_doc/_html/index.html
.
The documentation of the latest released version is also available online.