Depth-first search

easy

Recursive or iterative, with the call stack made visible either way. Turn on component restarting and the same traversal becomes a connected-components scan.

Worst O(V + E)Space O(V) stack depth
Loading the depth-first search engine…

Where to go next