Save this video free

Searching and Sorting Graphs

Kent Quanrud · 1:10:30 · Watch on YouTube

Part of Purdue University Fundamental Algorithms (Fall 2026). See all 20 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Kent Quanrud develops graph-search techniques from topological sorting through depth-first search (DFS) to strongly connected components (SCCs). He shows how DFS finishing order yields a second linear-time topological sort for directed acyclic graphs, then derives the two-pass Kosaraju algorithm, which finds every SCC in O(n + m) time by searching the reversed graph first and the original graph next.

Key takeaways

Chapters

0:00 Graph Basics: Vertices, Edges, and Representations
1:36 DAGs, Circuit Evaluation, and Topological Order
6:50 Topological Sorting by Repeatedly Removing Sources
10:00 The Cat Maze as a Graph-Reachability Problem
16:57 Why Naive Recursive Reachability Can Loop Forever
23:40 DFS Marks Vertices to Search Without Repeating Work
29:40 Proving DFS Reaches Every Vertex It Can Reach
35:24 DFS Finishing Times Order Reachable Vertices
40:26 Topological Sorting by Reversing DFS Postorder
44:49 Strong Connectivity and Component Equivalence Classes
48:52 Finding One SCC with a Reversed-Edge Graph
56:04 Why Repeated SCC Searches Need a Better Processing Order
1:03:32 DFS Finishing Order Identifies Sink Components
1:08:30 Kosaraju’s Two-Pass Algorithm Finds All SCCs

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:04 All right. Uh let's do um let's let's do some computer science. Okay. So, searching and sorting uh graphs today. So, okay. We're going to talk about a bunch of topics. You might have seen something called depth first search before in discrete math or something, but probably my perspective will be a little different. So, hopefully you've seen grass before. From here going forward, we're going to do a lot of stuff in grass. We had a couple of problems on your homework dealing with graphs. But you know, you know, you have vertices, you have edges. We'll often use n for the number of vertices, m for the number of edges. Uh there's two kinds of edges in this class. One is an undirected edge with like a mutual connection between two points. The other is a directed edge. There's some asymmetry. Okay? And depending on the context.

0:52 Now, uh you guys have probably been exposed to this before. What are some ways to maybe represent uh a graph in your computer? Yeah, >> you can do like a list. >> Yeah, a list. So, just for every vertex, I'm just going to list off like uh all the edges uh that leave it. Sometimes we call that an adjacency list. What else? Yeah, >> I forgot what it's called, but it's the matrix where >> Yeah, it's called a matrix. So an adjacy matrix where you you just make like a full n byn table like this. Anyway, it's not I don't think that uh these subtleties will come up really in any of our problems, but it's just good to be aware that you are probably representing on your computer somehow. Okay, so uh three main topics uh for today. We're going to talk about

1:42 something called directed asyclic graphs

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Kent Quanrud.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.