Graph Cycle Checker

Detect whether a directed graph contains a cycle using Kahn's algorithm and report which nodes could not be resolved.

Description

Check a directed graph for cycles with Kahn's algorithm and identify the nodes that cannot be resolved.

A directed graph cycle checker answers whether following directed edges can eventually return to a previously visited node. Cycles matter when validating dependency graphs, build pipelines, course prerequisites, workflow states, and any process that requires a one-way ordering.

When to use Graph Cycle Checker

  • Validate a dependency graph before scheduling work
  • Find why a topological ordering cannot be completed
  • Detect self-loops and multi-node circular references

How the calculation works

The calculator derives each node's indegree, repeatedly removes zero-indegree nodes, and reduces the indegrees of their outgoing neighbors. This is Kahn's algorithm. If every node is removed, the graph is acyclic. Any nodes left unresolved belong to a cycle or are downstream from one.

Interpreting the result

`hasCycle` is the primary result. `resolvedCount` shows how much of the graph could be peeled safely. `unresolvedNodes` narrows the investigation, but it is not a list of only cycle members: a node reachable from a cycle can also remain unresolved.

Important limitations

  • The input is interpreted as a directed adjacency map; reversing an edge can change the result.
  • The output detects cyclic structure but does not enumerate individual cycles.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies