vector of cell numbers for which adjacent cells should be found
directions
the number of directions in which cells should be connected: 4 (rook's case), 8 (queen's case), 16, or 'bishop'
pairs
Boolean. If TRUE, a matrix of pairs of adjacent cells is returned. If FAlSE, a vector of cells adjacent to from is returned (perhaps intersected with to)
target
Optional. Vector of target cell numbers that should be considered. All other adjacent cells are ignored
Value
matrix or vector with adjacent cells.
Details
Cell numbers start with 1 in the upper-left corner and increase from left to right and from top to bottom.