Can you help me out!
I could not understand this cycle detection in directed graph using dfs!
To detect a back edge, we can keep track of vertices currently in recursion stack of function for DFS traversal. If we reach a vertex that is already in the recursion stack, then there is a cycle in the tree. The edge that connects current vertex to the vertex in the recursion stack is a back edge. We have used recStack[] array to keep track of vertices in the recursion stack.
PLEASE DRY RUN BY UR OWN SELF ON PEN AND PAPER FOR BOTH A GRAPH WITHOUT LOOP AND ONE WITHOUT LOOP
USE THE PROCESS EXPLAINED with 2 BOOL ARRAYS and keep trace of nodes u`ll understand it easily
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.