Back

DFSDepth-First Search

Edit the tree or graph, pick a start node, then press Play. DFS follows one path as deep as it can, then backs up to try the next branch, using a stack to remember the way back.

Not found yet On the stack Exploring now Finished Color shows the depth, the number of steps down from the start.
Step 0 of 0

Traversal order

Each node appears here the moment DFS first reaches it. The rows below group nodes by depth, the number of steps down the path from the start.

Adjacency table

Every node and the nodes it connects to. It updates as you edit the graph. Click a row to select that node.

NodeConnected toDepthStatus

The algorithm

The highlighted lines are the ones running in the current step.