Help in cycle finding algorithm complexity

What is the time complexity of finding cycles in an undirected graph In this Algo?

It is given O(M + N).
Backtracking of the parent array wouldn’t take more time than O(M+N) ?