Does this do what you have in mind? pts = {{1, 1}, {1, 2}, {1234512345, 1234512345}, {1234512345, 1234512346}}; edges = Join @@ MapIndexed[ Thread[{#1, #2[[1]]}] &, Nearest[ pts -> "Index", pts, {\[Infinity], 1}, DistanceFunction -> ManhattanDistance ][[All, 2 ;;]] ]; SparseArray`StronglyConnectedComponents[SparseArray[edges ->_]] For diagonal connectivity the same code with `ManhattanDistance` replaced by `ChessboardDistance` should work.