Introduction
Lesson 1 of 9 in Coddy's Topological Sort - Graph Algorithms course.
Welcome back to the Graph Algorithms series! This time we work with a directed graph, where each edge has a direction: an edge u -> v means u must come before v.
Topological Sort arranges the vertices of a directed acyclic graph (DAG) into a line so that every edge points forward. It answers questions like "in what order can I take courses given their prerequisites?"
The graph is given as n (vertices 0 to n - 1) and edges, a flat array of directed pairs [u0, v0, u1, v1, ...] where each pair means u -> v.
Let's get started!
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.