Concept Flow - Connected Components Using BFS
Start with graph
Initialize visited set
For each node in graph
If node not visited?
No→Skip to next node
Yes
Start BFS from node
Add node to queue and visited
While queue not empty
Dequeue current node
For each neighbor
If neighbor not visited
Add neighbor to queue and visited
Repeat until queue empty
Mark one connected component found
Repeat for all nodes
Done: All connected components identified
We visit each node; if unvisited, we run BFS to find all nodes connected to it, marking one connected component. Repeat until all nodes are visited.
