getGridNeighbors function

Build adjacency list (4-way neighbors)