Depth-first search explores a graph by going as far as it can down one path before backtracking to try another — the natural recursion: visit a node, mark it, then recurse into each unvisited neighbor. In one sweep it reaches every node connected to the start, and the order it enters and leaves nodes (its discovery/finish times) powers a whole family of algorithms: topological sort, cycle detection, strongly connected components, and finding bridges and articulation points. It is how you solve a maze by always taking the next unexplored turn and unwinding at dead ends. From node 0 in a connected 5-node graph it reaches all 5.
The demo runs DFS from node 0 in a connected 5-node graph — it reaches all 5 nodes: live demo
“Exploring a graph needs a plan.” — DFS needs only recursion: go deep, mark, backtrack; it reaches everything connected. cited
A graph explored by plunging down every path and unwinding at the dead ends — recursion made a search. traversal
On the canonical compiler, DFS from node 0 in the connected graph reaches all 5 nodes: