Depth-first search

Depth-first search is a graph traversal algorithm that follows one path as far as possible before backtracking to explore alternatives. It can be implemented with recursion or an explicit stack.

Connect