import java.util.*; /** * The Union-Find algorithm. You must implement this. */ public class UnionFind { /** * Creates a completely disjoint set over n classes. * * @param n * The number of classes in the disjoint forest * @throws IllegalArgumentException * If n is not positive. */ public UnionFind (int n, Set vertices) { } /** * Finds the cannonical element for this node. * * @param node * Returns the cannonical class of this node * @throws IllegalArgumentException * If node is outside of the range [0, num_nodes-1] */ public int find (V node) { return -1; } /** * Merge the two cannonical classes can_one and can_two. * * @param a * The first cannonical class to merge. Note that these are * cannonical classes and not just nodes. * @param b * The second cannonical class to merge. * @throws IllegalArgumentException * If either a or ais not a valid node or is not the cannonical * element of its set. In other words, calls to this will * commonly look like union(find(one), find(two)). */ public void union (int a, int b) { } }