In-Degree
The number of incoming edges to a node. A node with 0 in-degree is a "source" and can be processed immediately.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Kahn's algorithm uses a BFS strategy to find a topological ordering. It works by maintaining the in-degree of each node and iteratively processing those with zero dependencies.
The number of incoming edges to a node. A node with 0 in-degree is a "source" and can be processed immediately.
When a node is processed, it's "removed" from the graph, reducing the in-degree of all its neighbors.
A queue stores all nodes whose in-degree has become 0, ensuring we process them in a valid topological order.
If we can't process all nodes because none have 0 in-degree, the remaining nodes must form a cycle.