Topological sort
mediumIndegree zero means nothing is waiting on this. If the queue empties while vertices remain, those vertices are waiting on each other - a cycle, detected with no extra check.
Worst
O(V + E)Space O(V)Loading the topological sort engine…