‣

We simple need to do either BFS or DFS starting from every unvisited vertex, and we get all strongly connected components. Below are steps based on DFS.

Pseudocode:

- Initialize all vertices as not visited.
- Do following for every vertex 'v'. (a) If 'v' is not visited before, call DFSUtil(v) (b) Print new line character

DFSUtil(v)

- Mark 'v' as visited.
- Print 'v'
- Do following for every adjacent 'u' of 'v'. If 'u' is not visited, then recursively call DFSUtil(u)

‣

A connected component of an **undirected graph** is a maximal set of nodes such that each pair of nodes is **connected by a path.**

‣

In

`DFS(G)`

, initialize `count = 0`

and increment for every `DFSUtil()`

call‣