gridadjacencymatrix: Create Adjacency Matrix for Spatial Grid
Description
Given the dimensions of a rectangular grid of points, this command
creates the adjacency matrix for the corresponding neighbourhood
graph, whose vertices are the grid points, and whose edges are the
joins between neighbouring grid points.
Usage
gridadjacencymatrix(dims, across = TRUE, down = TRUE, diagonal=TRUE)
Value
A sparse matrix.
Arguments
dims
Grid dimensions. An integer, or a vector of two integers.
First entry specifies the number of points in the \(y\) direction.
across
Logical value equal to TRUE if horizontal neighbours should
be joined.
down
Logical value equal to TRUE if vertical neighbours should
be joined.
diagonal
Logical value equal to TRUE if diagonal neighbours should
be joined.
Author
Adrian Baddeley.
Details
If N = prod(dims) is the total number of grid points,
then the result is an N * N sparse matrix with logical entries
equal to TRUE if the corresponding grid points are joined.