By using the Neighbor Contiguity algorithm, data points are grouped based on their proximity. As you mentioned, it is commonly used in GIS software such as ArcGIS for geographical data analysis.
This is how the algorithm works:
The data points are first divided into cells, each representing a small area on the map.
Next, the algorithm determines which cell each data point belongs to. It is considered a neighboring cell if it contains more than one data point.
A cluster of adjacent data points is created by grouping all data points that are neighbors together.
A map showing the relative proximity of data points is then created by repeating this process until all data points are assigned to clusters.
There are several ways you can identify neighbors based on queen or rook contiguities in a programming language that does not have this feature. In one approach, a nested loop would be used to iterate over all elements in the grid or matrix, and then a set of if statements would be used to check whether each element is a neighbor of the current element. Rook contiguities, for example, check whether the current element is in the same row or column as the element being checked. The element being checked is a neighbor if it is.
Another approach would be to use a graph data structure to represent the grid or matrix, and then use graph algorithms to find neighbors based on the rules of queen or rook contiguities. When searching for neighboring nodes in the same row or column as the current node, you could use a breadth-first search algorithm.
In general, the specific approach you choose will be based on the specifics of your implementation and the requirements of your project. However, using a nested loop or a graph data structure and algorithms can both be effective ways.