Stanford CS161 Lecture 9: Graph Representations, DFS, BFS, and Proofs About Search Order
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.