Connected compoents for directed graph

Sir i have doubt in no of connected components for directed graph

which node to choose first for dfs or bfs traversal to find connected components

for example if i choose node 3 then i will get 2 connected components

if i choose node 0 initial then i will get 3 conected components

Hi so since u are interested in only finding no of connected components in directed graphs what u would have to do is suppose u have an edge from u -> v, then u add an edge from v -> u in graph. do this for all the edges… thus it gets converted into undirected graph and u can apply normal dfs to find the no of connected components

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.