Finds the neighbours of cells in a multi-dimensional array (R.W. Payne).
||Whether to include diagonal cells (
||Saves the number of neighbours that have been found|
||Dimensions of the array|
||Locations of the cells in each dimension|
||Locations of the neighbours in each dimension|
NEIGHBOURS finds the neighbours of a set of cells in a multi-dimensional array. The
DIMENSION parameter supplies a list of scalars defining the dimensions of the array (i.e. the number of cells in each direction). The
CELLS parameter supplies a list of variates giving the locations of the cells in each dimension. The
NEIGHBOURS parameter supplies a list of variates to save their locations of the neighbours.
The default is to include diagonal neighbours, but you can set option
DIAGONALS=exclude to exclude them. The number of neighbours can be saved, in a scalar, by the
CAPTION 'NEIGHBOURS example'; STYLE=meta VARIATE [VALUES=2,3,3,4] x & [VALUES=2,3,4,5] y NEIGHBOURS 6,7; CELLS=x,y; NEIGHBOURS=xn,yn XAXIS 1; LOWER=0; UPPER=6 YAXIS 1; LOWER=0; UPPER=7 PEN 1,2; SYMBOL='circle'; SIZE=2; CSYMBOL='black','red'; CFILL='match' DGRAPH [TITLE='Including diagonal neighbours'] Y=y,yn; X=x,xn NEIGHBOURS [DIAGONALS=exclude] 6,7; CELLS=x,y; NEIGHBOURS=xn,yn DGRAPH [TITLE='Excluding diagonal neighbours'] Y=y,yn; X=x,xn