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: