Module Imperative.GenericRelationalValued
Imperative union find
- with generic types (parameterised by 'a)
- with relations
('a, 'b) Relation.ton edges between elements and representatives - with values attached to each representative This interface can easily be reused to remove any of the above features if needed.
Performs union by size, and path compression in find.
This is fully imperative and mutable.
- Create at most one node per
'a Elt.t - Do NOT perform
unionbetween related nodes
Parameters
module Node : Parameters.UF_NODE_WITH_VALUESignature
include Signatures.IMPERATIVE_GENERIC_RELATIONAL
with type 'a t = 'a Node.t
with type ('a, 'b) relation = ('a, 'b) Node.Relation.t
type 'a t = 'a Node.ttype ('a, 'b) relation = ('a, 'b) Node.Relation.ttype 'a node_through_relation = | NodeThoughRelation : 'b t * ('a, 'b) relation -> 'a node_through_relation
Existential wrapper for returning the representative
val find_representative : 'a t -> 'a node_through_relationFind the representative of a node, and the associated relation
check_related a b returns the relation between a and b if they are in the same class.
type 'a value = 'a Node.Value.ttype 'a value_through_relation = | ValueThroughRelation : 'b value * ('a, 'b) relation -> 'a value_through_relation
Existential wrapper for returning the value
type 'a node_and_value_through_relation = | NodeValueThroughRelation : 'b t * 'b value * ('a, 'b) relation -> 'a node_and_value_through_relation
Existential wrapper for returning the value and the representative
Find operations
val find_value : 'a t -> 'a value_through_relationFind the value of a node, and the associated relation
val find : 'a t -> 'a node_and_value_through_relationFind the value and representative of a node, and the associated relation