Delayed checking whether a vertex has been discovered until the vertex is popped from the stack in the depth-first search