Computes 4- or 8-direction neighbour pairs (from, to) for every input cell and filters out neighbours that fall off the raster top/bottom or wrap across left/right edges. Returns a 2-column integer matrix with column names "from" and "to". Equivalent to adj(..., pairs = TRUE) but without the data.table allocation/coercion overhead.
adjPairsMatrix(cells, numCol, numCell, directions)A 2-column integer matrix with columns named from and to.