Visit the nodes in BFS order. Begin your work from line 5 of the algorithm. The starting node s for the algorithm is node A.
Algorithm BFS(G, s)
- Initialize empty queue Q
- for each u ∈ V[G] do
- visited[u] ← false
- finished[u] ← false
- visited[s] ← true
- ENQUEUE(Q, s)
- while Q not empty do
- u ← DEQUEUE(Q)
- for each v ∈ Adj[u] do
- if visited[v] = false then
- visited[v] ← true
- ENQUEUE(Q, v)
- finished[u] ← true
- Clicking on a node the first time marks the node visited.
- Clicking on a node the second time marks the node finished.
Some additional problems.