Introduction
Lesson 1 of 9 in Coddy's Breadth-First Search - Graph Algorithms course.
Welcome back to the Graph Algorithms series! After Depth-First Search, we turn to Breadth-First Search (BFS), the other fundamental graph traversal.
Where DFS dives deep, BFS explores in layers: first the start vertex, then all of its neighbors, then everything two steps away, and so on. This layer-by-layer order is exactly what makes BFS find shortest paths in unweighted graphs.
As in the rest of the series, a graph is given as n (vertex count, 0 to n - 1) and edges, a flat array of undirected pairs [u0, v0, u1, v1, ...].
Let's get started!
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.