Kahn s Algorithm
Add all vertices with indegree 0 to the queue
Pop them and BFS, reducing the indegree of every node you visit Add new nodes with an indegree of 0 to the queue
Add all vertices with indegree 0 to the queue
Pop them and BFS, reducing the indegree of every node you visit Add new nodes with an indegree of 0 to the queue