Open atilante opened 5 months ago
First whiteboard sketch of Breadth-first search with fringe.
1 BFS-VISIT(G, s)
2 Initialize empty queue Q
3 for each u ∈ V[G] do
4 visited[u] ← false
5 finished[u] ← false
6 visited[s] ← true
7 ENQUEUE(Q, s)
8 while Q not empty do
9 u ← DEQUEUE(Q)
10 for each v ∈ Adj[u] do
11 if visited[v] = false then
12 visited[v] ← true
13 ENQUEUE(Q, v)
14 finished[u] = true
State of vertex
Line visited finished queue color
-------------------------------------------
6, 12 F->T
7, 13 enqueue unvisited -> fringe
9 dequeue fringe -> spanning tree
14 F->T
Atomic operations in visualization:
Possible points of confusion
Archie needed: a comment on Artturi's sketches.
Konsensus: visited BFS:ssä: tummempi vihreä solmulle.
Generic idea: how bring the concepts of "fringe" and "spanning" tree into all graph algorithm exercises?