What is a Topological Sort?

What is a Topological Sort?

Approach: Describe linear ordering of vertices for a DAG.

A linear ordering of vertices such that for every directed edge uv from vertex u to vertex v, u comes before v. This is only possible for Directed Acyclic Graphs (DAGs).

Follow-up: Can you use BFS for topological sort? (Kahn's algorithm)

Key concepts: dag, dependencies, indegree.