protocol
union_find_protocol
ï
Union-find data structure protocol.
logtalk_load(union_find(loader))
static
Public predicatesï
new/2
ï
Creates a new union-find data structure with a list of elements as keys.
static
new(Elements,UnionFind)
new(+list(element),?union_find)
- zero_or_one
make_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.
static
make_set(UnionFind,Element,NewUnionFind)
make_set(+union_find,+element,?union_find)
- zero_or_one
union/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.
static
union(UnionFind,Element1,Element2,NewUnionFind)
union(+union_find,+element,+element,?union_find)
- zero_or_one
union_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.
static
union_all(UnionFind,Elements,NewUnionFind)
union_all(+union_find,+list(element),?union_find)
- zero_or_one
find/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.
static
find(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.
static
find(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.
static
disjoint_sets(UnionFind,Sets)
disjoint_sets(+union_find,?sets)
- zero_or_one
Protected predicatesï
(none)
Private predicatesï
(none)
Operatorsï
(none)
See also