Agree with seriouscode, more like this would be really helpful.
Please where is the Coordinate class defined
the conditional check in the while loop only checks if neighborRow < numRows && neighborCol < numCols, therefore it’ll return neighbors outside the matrix as valid neighbor.
e.g. getting the neighbors of the top left node would return the non existent node to its left as valid!
This was nice.
How do you alter get_neighbors to get diagonal neighbors?
add the 4 indices for the diagonal nodes, e.g. top left is (r-1, c-1), bottom right is (r+1, c+1)