Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Build directed edges pre -> course and indegree counts. Remove zero-indegree nodes repeatedly; if all nodes are processed, there is no cycle.
A valid course order exists only if no cycle prevents completing prerequisites. Kahn’s process consumes all reachable zero-indegree courses only when graph is acyclic.
Updated Feb 2026