I'd like to automatically generate a graph where vertices correspond to (and have the coordinates of) points in an $A \times B$ integer lattice, and a graph is generated by connected vertices within a real-valued cutoff distance $r$. Is there a (relatively) automated manner of doing this in Mathematica v9? How can we display this graph properly, respecting the vertex coordinates?
Make an integer lattice:
Construct the graph:
By using Graph primitives.
I propose a general multidimensional solution with possibility to set periodic boundary conditions (I use a similar function in my own problem).
It returns the adjacency matrix for lattice with dimensions
1D lattice with 10 vertices
1D lattice with 10 vertices with periodic boundary conditions (denoted by negative lengths)
1D lattice with 10 vertices with periodic boundary conditions and
$a\times b$ 2D lattice (OP's question)
2D lattice with one periodic boundary
You can delete
It is fast for very big lattices ($1\,000\,000\times1\,000\,000$ adjacency matrix!)
Szabolcs's approach with pairwise distances inapplicable for such lattices.