|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.util.UnionFind
UnionFind manages a set of disjunct sets. These sets can be
searched for a given element in O(log n) time. The union operation on two
sets takes O(1). This datastructure is needed for Kruskal‘s algorithm
and other graph algorithms. Also geometrical algorithms can make use of it
sometimes.
Each set has one of its elements as the canonical element. It is undefined which element of the elements of a particular set happens to be the canonical element.
| Constructor Summary | |
UnionFind(int size)
Constructs a union find structure with size sets, each
set having one element. |
|
| Method Summary | |
int |
find(int e)
Finds the canonical element for the given element. |
int |
numberOfSets()
Returns the number of sets in the union-find structure. |
void |
union(int e,
int f)
Performs a union operation on two sets which are identified by their canonical element. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public UnionFind(int size)
size sets, each
set having one element.
size - number of sets to construct initially.| Method Detail |
public void union(int e,
int f)
e - canonical element for set onef - canonical element for set twopublic int find(int e)
e - element to search for.
public int numberOfSets()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||