Kahn's algorithm
Essentially, Kahn's algorithm works by keeping track of the number of incoming edges into each node (indegree).
- Finds nodes with no incoming edge, that is, nodes with zero indegree (no dependency).
- Stores the nodes with zero indegree in a stack/queue and deletes them from the original graph.