Breadth first search
Breadth first search (BFS) is a type of traversal that focuses on visiting the nodes of the same level (or neighbors) before going deeper into the graph (to the neighbors of the neighbors).
Another condition to take into account is that we should visit each node just once. Let's see an example with the following graph:
In step 1, we visit node A. Then we pass to the first child of A: node B. We visit all the children of B: C, D, and E, before going into its grandchildren: F.
We have already implemented
AdjacencyList structs. We are going to make an example of BFS based on a graph built with classes ...