Percolation algorithm