I am new to graph theory, and so far I have learned only BFS and Disjoint sets in graph theory. If there is a cycle in a given, undirected, connected graph, can I find it using BFS ? My intention is to print all the vertices in the cycle. Thanks in advance.
Yes, if the graph is undirected, but it is very inefficient compared to DFS. If a graph was a directed graph, you'd have to remember if you visited the node or not, and also how you got there. BFS, which searches by "levels" from the origin will not be compatible with these parameters.