Grids

A grid is just a 2D array. We can assign each square $A[i][j]$ a coordinate-pair $(i, j)$ based on their index.

Adjacency

Usually, we consider two squares to be neighbors or adjacent if they share an edge, i.e. exactly one of their x and y coordinates differs by 1. This case is called 4-adjacency, and should be assumed unless otherwise mentioned.

The other case admits two squares to be adjacenct if they share an edge or a corner (8-adjacency).


Authored by s16f22