public void union(final int p, final int q) {
        final int rootP = root(p);
        final int rootQ = root(q);
        if (rootP == rootQ) {
            return;
        }
        root[rootP] = rootQ;
    }