Breadth First Search (BFS)

Discover how to traverse graphs using breadth first search.

The second important traversal algorithm for graphs is breadth-first search (BFS). The main concept of BFS is that the closest not yet explored node is explored first. This is exactly the opposite strategy compared to DFS.

Explanation of BFS

Let’s execute the BFS algorithm on an example graph as we did for DFS.

Get hands-on with 1400+ tech skills courses.