Kahn's Algorithm - Topological Sorting
Kahn's algorithm is a method used to perform a topological sort on a directed acyclic graph(DAG). A topological sort produces a linear ordering of vertices such that every directed edge from vertex u to vertex v, u comes before v in the ordering. Main applications of the algorithm are
- Course prerequisite scheduling
- Build dependency resolution
- Task scheduling with dependencies
- Detecting cycles in directed graph
Interactive Visualization
Problems
207. Course Schedule
802. Find Eventual Safe States
1136. Parallel Courses
2115. Find All Possible Recipes from Given Supplies
Medium1 solution1 playground
Solutions: