Interface DisjointSetStruct
-
- All Known Implementing Classes:
HugeAtomicDisjointSetStruct
public interface DisjointSetStruct
Disjoint-set-struct is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets.- See Also:
- Wiki
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongNodePropertyValues
asNodeProperties()
Wraps the DisjointSetStruct in an LongNodeProperties interfaceboolean
sameSet(long p, long q)
Check if p and q belong to the same set.long
setIdOf(long nodeId)
Find set Id of element p.long
size()
Number of elements stored in the data structure.void
union(long p, long q)
Joins the set of p (Sp) with set of q (Sq).
-
-
-
Method Detail
-
union
void union(long p, long q)
Joins the set of p (Sp) with set of q (Sq).- Parameters:
p
- an item of Spq
- an item of Sq
-
setIdOf
long setIdOf(long nodeId)
Find set Id of element p.- Parameters:
nodeId
- the element in the set we are looking for- Returns:
- an id of the set it belongs to
-
sameSet
@TestOnly boolean sameSet(long p, long q)
Check if p and q belong to the same set. use only in tests.- Parameters:
p
- a set itemq
- a set item- Returns:
- true if both items belong to the same set, false otherwise
-
size
long size()
Number of elements stored in the data structure.- Returns:
- element count
-
asNodeProperties
default LongNodePropertyValues asNodeProperties()
Wraps the DisjointSetStruct in an LongNodeProperties interface- Returns:
- wrapped DisjointSetStruct
-
-