A depth-first search (DFS) is an algorithm for traversing a finite graph.