I have a set $S$ of $n$ 2-dimensional points. We can compute a distance matrix (Euclidean distance) for $S$ using say this answer. I wish to form an $n$-vertex graph having the points $S$ as vertices, with an edge between two points if their distance is exactly $d$ (for some fixed $d > 0$). What's an idiomatic way of achieving this?
For example, we could start with the following:
pts = {{0, 0}, {0, 1}, {4, 4}, {0, 2}, {1, 2}}; (* Or whatever *)
distances = With[{tr = Transpose[pts]},
Function[point, Sqrt[Total[(point - tr)^2]]] /@ pts];
Alternatively, we could form all 2-subsets of pts
, and compute the Euclidean distance for each. However, I'm a bit stuck as to how to continue without resorting to an explicit loop.