Find if there is a path between two vertices in a directed graph

Why do you need to have 3 states (“Visited, &…

Anonymous - Aug 4, 2016

Why do you need to have 3 states (“Visited, “Unvisited”, and “Visiting”)? It seems like we do the same thing - adding the node to the queue - if it’s unvisited, but there is no functional distinction between visited and visiting (in either state we skip it - we won’t enqueue it and we won’t check against it). So, aside from debugging, I don’t see any benefit of having it. Am I wrong?

Hi..I agree that only visited and unvisited was enough.Thanks.


See also