Package com.zybooks.dsaj.graph
Class Partition<E>
java.lang.Object
com.zybooks.dsaj.graph.Partition<E>
- Type Parameters:
E
- the element type
A Union-Find structure for maintaining disjoint sets.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionFinds the cluster containing the element identified by Position p and returns the Position of the cluster's leader.makeCluster
(E e) Makes a new cluster containing element e and returns its position.void
Merges the clusters containing elements with positions p and q (if distinct).
-
Constructor Details
-
Partition
public Partition()
-
-
Method Details
-
makeCluster
Makes a new cluster containing element e and returns its position. -
find
Finds the cluster containing the element identified by Position p and returns the Position of the cluster's leader. -
union
Merges the clusters containing elements with positions p and q (if distinct).
-