Module 8 · Graphs and Trees · BFS on Grid

Find whether path exists

A grid is a graph: every cell is a vertex, joined to the cells left, right, above and below it. BFS from the source spreads through open cells, and walls simply never enter the queue.