protocol
union_find_protocol
Union-find data structure protocol.
logtalk_load(union_find(loader))staticPublic predicates
new/2
Creates a new union-find data structure with a list of elements as keys.
staticnew(Elements,UnionFind)new(+list(element),?union_find) - zero_or_onemake_set/3
Makes a new set by creating a new element with a unique key Element, a rank of 0, and a parent pointer to itself. The parent pointer to itself indicates that the element is the representative member of its own set.
staticmake_set(UnionFind,Element,NewUnionFind)make_set(+union_find,+element,?union_find) - zero_or_oneunion/4
Merges the two trees, if distinct, that contain the given elements. The trees are joined by attaching the shorter tree (by rank) to the root of the taller tree. Fails if any of the elements is not found.
staticunion(UnionFind,Element1,Element2,NewUnionFind)union(+union_find,+element,+element,?union_find) - zero_or_oneunion_all/3
Merges the distinct trees for all the given elements returning the resulting union-find data structure. Fails if any of the elements is not found.
staticunion_all(UnionFind,Elements,NewUnionFind)union_all(+union_find,+list(element),?union_find) - zero_or_onefind/4
Finds the root element of a set by following the chain of parent pointers from the given element. Root is the representative member of the set to which the element belongs, and may be element itself. Fails if the element is not found.
staticfind(UnionFind,Element,Root,NewUnionFind)find(+union_find,+element,?element,?union_find) - zero_or_one
Path compression: The structure of the tree containing the element is flattened by making every node point to the root whenever this predicate is used on it.
find/5
Same as the find/4 predicate, but returning also the rank of the root. Fails if the element is not found.
staticfind(UnionFind,Element,Root,Rank,UnionFindOut)find(+union_find,+element,?element,?rank,?union_find) - zero_or_one
Path compression: The structure of the tree containing the element is flattened by making every node point to the root whenever this predicate is used on it.
disjoint_sets/2
Returns the list of disjoint sets in the given union-find data structure.
staticdisjoint_sets(UnionFind,Sets)disjoint_sets(+union_find,?sets) - zero_or_oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)
See also