0 votes 0 votes Can BFS and DFS both work cyclic and acyclic graphs?! Kindly explain for each of 'em. Thank you! Algorithms algorithms graph-algorithms descriptive + – iarnav asked Dec 9, 2017 • retagged Jul 6, 2022 by Lakshman Bhaiya iarnav 708 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Yes, BFS and DFS works for any graph in general. There is nothing different in the procedure of bfs/dfs if there's a cycle in the graph. Moreover you can also use DFS to detect cycle in an undirected/directed graph(links given below :)) http://www.geeksforgeeks.org/detect-cycle-in-a-graph/ http://www.geeksforgeeks.org/detect-cycle-undirected-graph/ jaideeppyne answered Dec 9, 2017 jaideeppyne comment Share Follow See 1 comment See all 1 1 comment reply Markzuck commented Dec 30, 2018 reply Follow Share @jaideeppyne Both DFS and BFS can be used to detect cycles right and not just dfs? 0 votes 0 votes Please log in or register to add a comment.