Graph Representations, DFS, BFS, and Proofs About Search Order | Stanford CS161 Lecture 9
DFS and BFS both scan an adjacency-list graph in O(n+m); DFS finish times produce a topological order for a DAG, while BFS layers equal exact unweighted shortest-path distances.