I am implementing stack for dfs traversal, I am trying to give time stamps for each node, timestamp is given only when a node is new(start_time) or when we are done with that node i.e., no other new nodes can be traversed from that node, this time is finish_time i am not getting as expected and I am not finding my way efficient to store this.
I am considering UNDIRECTED GRAPH
Suppose there are 6 nodes and 8 edges connecting them,
when a node is not visited, I am putting it into stack and traversing all its adjacent nodes, if adjacent nodes all visited , I am increasing counter and after the loop I am checking If no nodes are visited in the loop, that means the the node has no other path left so I am popping it out from stack.
here is MY CODE
In the code as start_time is set to 12 which is wrong it should be 0, so how can I set it to zero instead of 12.
I am using count in my program to check every time weather any node can be visited from the current node,I am unable to do this without
countvariable, how can I do this as in recursive we dont use any such count, start_time is filled before recursive function is called and end_time after the call.