Give the reasons for the above my query
I find the above questions of the traverse of graph. Bfs and DFS both are the traverse to detect the cycle in a graph but most is the dfs why this is the best to solve the graph of a cycle
1.When I code graph traversals, the dfs stack is easier to implement than a queue.
2.Also we can often use less memory for having one long path and not all in parallel.
3.It depends on your graph to use DFS or BFS. This can optimize a choosen bottleneck and yield better average/minimal/maximal complexity.
Edit: duplicate at Why DFS and not BFS for finding cycle in graphs