complexitydsagraphs
A topological sort can reveal a directed cycle
Anonymous
For a directed graph, repeatedly remove a node with indegree zero and reduce the indegree of its outgoing neighbors. If fewer than all nodes are processed, the graph contains a cycle. With adjacency lists, this takes O(n + m) time.
0