@Override
	public void union(int p, int q)
	{
		int pID = find(p); // component of p
		int qID = find(q); // component of q

		// Do nothing if p and q belong to the same component
		if (pID == qID)
			return;
		
		//Label all nodes with component id, pID to qID
		for(int i = 0; i < id.length; i++)
			if (id[i] == pID)
				id[i] = qID;
		
		componentCount--;
	}