Cycle in a directed graph
A DFS colours the nodes on its current path; arriving at one of them again means a cycle. Kahn's BFS sees it differently: nodes on a cycle wait on each other forever, so their in-degree never reaches 0.
A DFS colours the nodes on its current path; arriving at one of them again means a cycle. Kahn's BFS sees it differently: nodes on a cycle wait on each other forever, so their in-degree never reaches 0.