UnionFind.UnionFindQuantitative union find
module ValMap = TMaptype 'v node = ('v * Z.t) * int(value * offset) ref * size of equivalence class
val equal_node :
'v. ('v -> 'v -> Ppx_deriving_runtime.bool) ->
'v node ->
'v node ->
Ppx_deriving_runtime.boolval compare_node :
'v. ('v -> 'v -> Ppx_deriving_runtime.int) ->
'v node ->
'v node ->
Ppx_deriving_runtime.intval hash_node : ('v -> int) -> 'v node -> intval equal : t -> t -> Ppx_deriving_runtime.boolval compare : t -> t -> Ppx_deriving_runtime.intval hash : t -> intexception UnknownValue of T.tval empty : 'a ValMap.tval parent : ('a * 'b) ValMap.t -> ValMap.key -> 'a`parent uf v` returns (p, z) where p is the parent element of v in the union find tree and z is the offset.
Throws "Unknown value" if v is not present in the data structure.
val parent_opt : ('a * 'b) ValMap.t -> ValMap.key -> 'a option`parent_opt uf v` returns Some (p, z) where p is the parent element of v in the union find tree and z is the offset. It returns None if v is not present in the data structure.
val parent_term : (('a * 'b) * 'c) ValMap.t -> ValMap.key -> 'aval parent_offset : (('a * 'b) * 'c) ValMap.t -> ValMap.key -> 'bval subtree_size : ('a * 'b) ValMap.t -> ValMap.key -> 'bval modify_size :
ValMap.key ->
((T.t * 'a) * 'b) ValMap.t ->
('b -> 'b) ->
((T.t * 'a) * 'b) ValMap.tModifies the size of the equivalence class for the current element and for the whole path to the root of this element.
The third parameter `modification` is the function to apply to the sizes.
val modify_parent :
(('a * 'b) * 'c) ValMap.t ->
ValMap.key ->
('a * 'b) ->
(('a * 'b) * 'c) ValMap.tval modify_offset :
(('a * 'b) * 'c) ValMap.t ->
ValMap.key ->
('b -> 'b) ->
(('a * 'b) * 'c) ValMap.tReturns true if each equivalence class in the data structure contains only one element, i.e. every node is a root.
val is_root :
((T.t * 'a) * 'b) ValMap.t ->
ValMap.key ->
Ppx_deriving_runtime.boolReturns true if v is the representative value of its equivalence class.
Throws "Unknown value" if v is not present in the data structure.
For a variable v it returns the reference variable v' and the offset r'. This find performs path compression. It returns als the updated union-find tree after the path compression.
Throws "Unknown value" if v is not present in the data structure. Throws "Invalid Union Find" if it finds an element in the data structure that is a root but it has a non-zero distance to itself.
For a variable v it returns the reference variable v' and the offset r'. This find DOES NOT perform path compression.
Throws "Unknown value" if t is not present in the data structure. Throws "Invalid Union Find" if it finds an element in the data structure that is a root but it has a non-zero distance to itself.
val compare_repr_v : (T.t * 'a) -> (T.t * 'b) -> Ppx_deriving_runtime.intCompare only first element of the tuples (= the parent term). It ignores the offset.
val union :
((T.t * Z.t) * int) ValMap.t ->
ValMap.key ->
ValMap.key ->
Z.t ->
T.t * ((T.t * Z.t) * int) ValMap.t * boolParameters: uf v1 v2 r
changes the union find data structure `uf` such that the equivalence classes of `v1` and `v2` are merged and `v1 = v2 + r`
returns v,uf,b where
Returns a list of equivalence classes.
Throws "Unknown value" if the data structure is invalid.
val get_representatives : ((T.t * 'a) * 'b) ValMap.t -> ValMap.key listReturns a list of representative elements.