Implement the union-by-size heuristic first and make sure it works before adding the path-compression heuristic.