Loading...
Depth-First Search explores as far as possible along each branch before backtracking. It naturally reveals recursive structure, discovery/finish times, and supports topological sorting and strongly connected components detection.
Go deep then backtrack
Call stack or explicit stack
Detects back edges
Recursively visit an undiscovered vertex, then explore each undiscovered neighbor. Backtracking unwinds recursion revealing finishing order. Edge classification (tree, back, forward, cross) emerges from discovery/finish timestamps.