Some variant implementations of the Union-Find algorithm
Go to file
Christian Rinderknecht 43eb5dd13f The function [repr] returns now an optional value instead of raising an exception.
Also, [is_equiv] does not raise an exception anymore.
2019-10-19 19:39:25 +02:00
.links Support for the OCaml Makefile and git (Version.ml). 2018-08-19 20:53:42 +02:00
.PartitionMain.tag Support for the OCaml Makefile and git (Version.ml). 2018-08-19 20:53:42 +02:00
build.sh I removed the useless module Item. 2018-08-12 15:12:27 +02:00
clean.sh First import of some implementations of the Union/Find algorithm in OCaml. 2018-08-12 15:04:27 +02:00
dune Added support for building the library with dune. 2019-03-24 14:32:51 +01:00
dune-project Added support for building the library with dune. 2019-03-24 14:32:51 +01:00
LICENSE Initial commit 2018-07-30 16:55:59 +02:00
Makefile.cfg Support for the OCaml Makefile and git (Version.ml). 2018-08-19 20:53:42 +02:00
Partition.mli The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
partition.opam Added support for building the library with dune. 2019-03-24 14:32:51 +01:00
Partition1.ml The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
Partition2.ml The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
Partition3.ml The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
Partition0.ml The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
PartitionMain.ml The function [repr] returns now an optional value instead of raising an exception. 2019-10-19 19:39:25 +02:00
README.md Added support for building the library with dune. 2019-03-24 14:32:51 +01:00

Some implementations in OCaml of the Union/Find algorithm

All modules implementing Union/Find can be coerced by the same signature Partition.S.

Note the function alias which is equivalent to equiv, but not symmetric: alias x y means that x is an alias of y, which translates in the present context as x not being the representative of the equivalence class containing the equivalence between x and y. The function alias is useful when managing aliases during the static analyses of programming languages, so the representatives of the classes are always the original object.

The module PartitionMain tests each with the same equivalence relations.

Partition0.ml

This is a naive, persistent implementation of Union/Find featuring an asymptotic worst case cost of O(n^2).

Partition1.ml

This is a persistent implementation of Union/Find with height-balanced forests and without path compression, featuring an asymptotic worst case cost of O(n*log(n)).

Partition2.ml

This is an alternate version of Partition1.ml, using a different data type.

Partition3.ml

This is a destructive implementation of Union/Find with height-balanced forests but without path compression, featuring an asymptotic worst case of O(n*log(n)). In practice, though, this implementation should be faster than the previous ones, due to a smaller multiplicative constant term.