# Find critical radius in percolation

I would like to examine the percolation from the left edge to the right edge on random lattice.

Suppose I have a rectangle with N random points on it.

randPts = Table[{RandomReal[{-1, 1}], RandomReal[{-2, 2}]}, {N=100}]


Now I simultaneously increase the radius of each points to r. For a critical r*, there should be a path I can connect from the left edge to right edge. I want to find the critical r* that the percolation happens.

I know that there is a related answer: Finding a percolation path But this answer only connects the leftmost point to the rightmost point. These points can be isolated themselves, so they might not in the path I am looking for.

You can take all nodes that are connected to the left edge and connect those to each other. Then do the same for all nodes connected to the right edge. Then connect all nodes that are close to each other. Then pick one of the nodes connected to the left edge, and one of the nodes connected to the right edge, and see if you can find a path between them.

randPts = Table[{RandomReal[{-1, 1}], RandomReal[{-2, 2}]}, {N, 100}];
r = 0.4;
leftEdge = -1;
rightEdge = 1;
leftEdgeNodes = Select[randPts, #[] - r < leftEdge &];
rightEdgeNodes = Select[randPts, #[] + r > rightEdge &];
graph = NearestNeighborGraph[randPts, {All, r}];

I'm not sure that NearestNeighborGraph does what you want, please have a look to see that you can use it. Otherwise, you can use the approach of Verbeia in that other Q&A that you linked to.