# The problem in finding a connected path through square lattice

I have a LxL square lattice. I randomly chose some points on this lattice and take them as my points. I want to find a connected path from left(0) to right(L). Below is my code:

    foo[points : {{_?NumericQ, _?NumericQ} ..}] :=
Module[{leftEdgeNodes = Select[points, #[[1]] == 0 &],
rightEdgeNodes = Select[points, #[[1]] == L &]},
If[leftEdgeNodes != {} && rightEdgeNodes != {},
FindShortestPath[