Graphs & Pathfinding
Arrays put values in a line. Graphs let anything connect to anything else. A maze is a graph too: each open cell is a vertex, and a move to a neighbor is an edge.
Draw walls, paint terrain, and watch the frontier spread from a starting point to a goal. BFS looks for the fewest moves, DFS follows a branch, and Dijkstra and A* look for the cheapest route. Press play, step in either direction, or scrub through the run. The comparison puts them on the same board, and the BFS and DFS pages also include node-and-edge graphs and trees.
Give every algorithm the same maze. Compare how far each explores, how many moves its route takes, and what that route costs.
Breadth-first search fans out one layer at a time. Watch its queue grow and see why the first route it finds through an unweighted graph is always a shortest path.
More graph algorithms coming weekly.