01Chapter 1: Representing Graphs for TraversalDepth-first search (DFS) repeatedly asks one question: "Which vertices can I reach from here?" The way you store a graph decides how quickly that question gets answered. This chapter sets up the representation used in the rest of the tutorial.2 min read
02Chapter 2: Go Deep, Then Backtrack: The Core IdeaThis chapter assumes you can read basic Python and know what vertices and edges are. It also assumes you understand how recursive calls stack up. It builds on the adjacency-list representation from the previous chapter.3 min read
03Chapter 3: Remembering Where You Have BeenThis chapter assumes you can read Python, know how sets and dictionaries work, and are comfortable with recursion. It uses the adjacency-list dictionaries from the earlier chapters.2 min read
04Chapter 4: Writing DFS RecursivelyThis chapter assumes you are comfortable with Python functions, sets, and dictionaries, and that you know how recursion uses the call stack. It builds on the adjacency-list representation and the visited set from earlier chapters.2 min read
05Chapter 5: Replacing Recursion with an Explicit StackThis chapter assumes you have read the earlier chapters on adjacency lists, visited tracking, and recursive DFS. It also assumes you know how a call stack works and how a Python list behaves as a stack through append and pop.3 min read
06Chapter 6: Why DFS Runs in O(V + E)This chapter assumes you can read the recursive and iterative DFS from the previous chapters, you know Big-O notation, and you know that Python set membership checks take O(1) time on average. Here V is the number of vertices and E is the number of edges.3 min read
07Chapter 7: Visiting Every Vertex: The DFS ForestThis chapter assumes you already know recursive DFS from a single start vertex, the visited-set technique, and the difference between directed and undirected graphs.2 min read
08Chapter 8: Discovery and Finish TimesThis chapter assumes you can write recursive DFS and that you know how the outer loop over all vertices builds a DFS forest. Here we add two numbers to every vertex. They record when DFS first reaches the vertex and when it has finished with it.2 min read
09Chapter 9: Classifying Edges During DFSThis chapter assumes you know how recursive DFS works, how the DFS forest is built when you launch a search from every unvisited vertex, and how discovery and finish times are recorded. All examples use directed graphs stored as adjacency-list dictionaries.2 min read
10Chapter 10: Detecting CyclesThis chapter assumes you know recursive DFS, visited sets, and the edge classes from the previous chapter: tree, back, forward, and cross edges. The key fact you need is that a graph has a cycle exactly when DFS finds a back edge. A back edge points from a vertex to one of its ancestors in the D3 min read
11Chapter 11: Topological Sorting from Finish OrderThis chapter assumes you know recursive DFS, the full-graph outer loop that builds a DFS forest, finish times (post-order), and three-color cycle detection from the earlier chapters.3 min read
12Chapter 12: Finding Connected ComponentsThis chapter assumes you can write recursive DFS over an adjacency-list dictionary. It also assumes you know the outer loop from the DFS forest chapter, which starts a new search from every vertex that has not been visited yet. Everything here applies to undirected graphs. Directed graphs need a2 min read
13Chapter 13: DFS on Grids: Flood Fill and Counting IslandsThis chapter assumes you can already write recursive DFS over an adjacency list and that you know what a connected component is. Here you apply the same traversal to a 2D grid, where the graph is never built explicitly.2 min read
14Chapter 14: Path Finding and Backtracking SearchThis chapter assumes you can already write recursive DFS with a visited set and that you know DFS costs O(V + E) on an adjacency list. It adds two things to that. The first is recording the path you followed. The second is undoing your choices so you can try other ones. That second habit is called b2 min read
15Chapter 15: Strongly Connected ComponentsThis chapter assumes you already know recursive DFS, finish order (post-order), and topological sort from earlier chapters. You should also be comfortable with directed graphs stored as adjacency-list dictionaries.2 min read
16Chapter 16: Bridges and Articulation Points with Low-Link ValuesThis chapter assumes you already know recursive DFS, discovery times, and how DFS labels tree edges and back edges. All graphs here are undirected, connected or not, and stored as adjacency lists.2 min read
17Chapter 17: Choosing Between DFS, BFS, and Iterative DeepeningThis chapter assumes you know recursive and iterative DFS, the O(V + E) analysis from earlier chapters, and how a queue differs from a stack. The question here is practical. You have a search problem, so which traversal should you use?2 min read