Uses a union-find data structure to check if a system percolates.