Breadth-First Search
Start at 0, goal 5. Explore one node at a time.
Graph (0 → 5)
0
1
2
3
4
5
edges: 0-1 0-3 1-2 1-4 3-4 4-5
Frontier (FIFO queue)
0
Visited order
0
BFS trace so far:
0
1/7
BFS finds the shortest path in unweighted graphs but uses O(bd) memory. DFS dives deep with O(bd) memory but can miss the shortest path and wander forever in infinite graphs.