Grid and adjacency graph exploration using queue BFS or stack DFS
2 standard techniques
Paint connected component; count islands.
Layers = distance in unweighted graphs.