# Depth-first search (DFS)

Last edited: 2023-11-11

This is a way of traversing a graph (could be a directed graph or undirected graph ). It explores all the way down one branch of the graph before tracing and exploring other branches.

The generally runs in $O(\vert V \vert + \vert E \vert)$ time.

# Examples