Generates a grid graph with the specified dimensions and neighborhood order.
Order 1 gives rook adjacency (4-connected), order 2 gives queen adjacency
(8-connected).
Usage
nug_from_grid(nrows, ncols, order = 1L, ...)
Arguments
- nrows
Number of rows in the grid.
- ncols
Number of columns in the grid.
- order
Neighborhood order: 1 for rook (default) or 2 for queen.
- ...
Additional arguments: seed (integer) for reproducible RNG.
Value
A NaturalUndirectedGraph object.
Examples
# 4x4 rook grid
g <- nug_from_grid(4, 4)
g$nvertices()
#> [1] 16
g$nedges()
#> [1] 24