Tools for agents: Directed graph cycle components

Locate mutually reachable node groups and actual directed cycles, then build the acyclic component graph.

Connect with MCP

{
  "mcpServers": {
    "super-agent-tools": {
      "url": "https://app.getsupers.com/sites/agent-graph-components/mcp"
    }
  }
}
Streamable HTTP · No API key · Stateless

Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.

Call analyze_graph_components

Input maps every nonempty node ID to its outgoing target IDs. Every target must be declared, even when it has no outgoing edges; duplicate targets fail. Self-loops are allowed. A strongly connected component contains nodes mutually reachable by directed paths. A component is cyclic exactly when it contains multiple nodes or its singleton has a self-loop. Downstream nodes outside the cycle are not labeled cyclic. Condensation edges connect different components, deduplicate parallel connections, and form a DAG. Nodes inside components and components by their first node are sorted lexicographically; IDs are zero-based in that order, not topological order, and may change when input changes. Empty graphs are acyclic. This computes graph structure only; it does not infer edge direction, diagnose semantic deadlock, break cycles, schedule or execute tasks. For dependency data, consistently choose edges from prerequisite to dependent or the reverse; component membership is unchanged by reversing every edge, but condensation direction reverses.

Input and output schemas
{
  "name": "analyze_graph_components",
  "title": "Directed graph cycle components",
  "description": "Find strongly connected components of a directed graph and return cyclic components plus deduplicated condensation edges. Input maps each node to its outgoing neighbors.",
  "inputSchema": {
    "properties": {
      "graph": {
        "additionalProperties": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "title": "Graph",
        "type": "object"
      }
    },
    "required": [
      "graph"
    ],
    "title": "analyze_graph_componentsArguments",
    "type": "object"
  },
  "outputSchema": {
    "additionalProperties": true,
    "title": "analyze_graph_componentsDictOutput",
    "type": "object"
  },
  "icons": null,
  "annotations": {
    "title": null,
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "meta": null,
  "execution": null
}

Run the example to see the actual result.

HTTP alternative

POST https://app.getsupers.com/sites/agent-graph-components/call
Content-Type: application/json

{
  "graph": {
    "build": [
      "review"
    ],
    "review": [
      "build",
      "publish"
    ],
    "publish": [
      "notify"
    ],
    "notify": [],
    "isolated": []
  }
}

The HTTP and MCP interfaces execute the same implementation. Validation errors are returned explicitly. See the tool notes above for its supported inputs and behavior.

Condensing mutually reachable nodes preserves downstream direction

Read the explanation

The saved example declares five nodes and four directed edges. Build points to review. Review points back to build and forward to publish. Publish points to notify; isolated has none. Build and review are mutually reachable, so they form one strongly connected component with two nodes. Publish, notify and isolated each form a singleton. Five original nodes become four components. At sixty pixels per count the node bar is three hundred and component bar two hundred forty. This describes the supplied graph and documented contract without calling its backend. A component is cyclic when it contains multiple nodes or a singleton has a self loop. The two-node build review group is cyclic. Publish and notify are downstream, but neither can return to build or review and neither is labeled cyclic. Collapsing the two internal edges removes them from condensation. The remaining two edges connect the cyclic component to publish, then publish to notify. At eighty pixels per edge the original count four measures three hundred twenty and condensation count two one hundred sixty. Condensation is acyclic, but that alone does not resolve a dependency conflict or execute a safe schedule. The documented IDs follow lexicographic first-node sorting, not topological order. In this example build review is component zero, isolated one, notify two and publish three. Thus condensation edges are zero to three and three to two. The ID three can precede ID two along a directed path. Four components still form the DAG even though their numbers are not a valid execution order. At seventy pixels per item four components measure two hundred eighty, two edges one hundred forty and one cyclic component seventy. The shared app script is absent in the saved offline page; local text edits are possible but actual HTTP or MCP execution is deliberately not invoked.

Kosaraju's Algorithm and DAG Condensation in Directed Workflow Graphs

How does the tool detect cyclic dependency deadlocks and condense directed graphs into acyclic DAGs?

This tool implements an iterative version of Kosaraju's two-pass algorithm to decompose any finite directed graph into its strongly connected components (SCCs) and construct the acyclic condensation graph. The first pass records the post-order finishing times of nodes in the original graph using a depth-first traversal. The second pass traverses the transposed graph in reverse finishing order, grouping nodes that can mutually reach each other into maximal subgraphs. Components containing multiple nodes or a self-loop are flagged as cyclic, and directed edges between separate components are deduplicated to produce a strict directed acyclic graph (DAG).

The tool analyzes discrete graph connectivity only; it does not assign task execution order, break cyclic dependencies, or resolve race conditions. Component IDs are assigned based on the lexicographical order of each component's first node name rather than the topological sort order of the condensation DAG. Downstream nodes dependent on a cycle are not flagged as cyclic unless they can reach back into the cycle. Self-loops count as cyclic components, and every target vertex must be explicitly declared as a key in the input dictionary.

Try a worked example

Click 'Run tool' with the default fixture: 'build' points to 'review', 'review' cycles back to 'build' and extends to 'publish', 'publish' targets 'notify', and 'isolated' has no incident edges. The tool evaluates 5 nodes and returns 4 components: component 0 containing ['build', 'review'] marked cyclic=True, and three acyclic singleton components for 'isolated', 'notify', and 'publish'. The condensation graph collapses the cyclic subsystem into a single vertex with deduplicated outgoing edges from component 0 to component 3 ('publish'), and component 3 to component 2 ('notify'), confirming that the macro-level dependency graph is acyclic even when internal cycles exist.

Kosaraju-Sharir Two-Pass Traversal Mechanism

Kosaraju's algorithm partitions a directed graph into strongly connected components in linear time Θ(V + E) by leveraging graph transposition. The first pass performs a depth-first search on the original graph, pushing nodes onto a finish stack in post-order. Because earlier-finishing subtrees cannot reach later-finishing ancestral subtrees in the transposed graph, reversing the traversal order isolates each maximal mutually reachable component cleanly. Kosaraju's algorithm - Wikipedia

In the tool's Python implementation, this is executed iteratively with explicit call stacks: `reverse` builds the transpose graph by mapping each `neighbor` back to `node`, the forward stack accumulates `finish` order, and the backward stack collects all vertices reachable in the transposed structure into `groups`.

Condensation Graph and DAG Properties

A directed graph is acyclic if and only if every strongly connected component is trivial, meaning it consists of a single vertex without a self-loop. When components are contracted into super-nodes, the resulting condensation graph is guaranteed to be a directed acyclic graph (DAG), which allows orchestration engines to schedule inter-component stages without encountering recursive deadlocks. Strongly connected component - Wikipedia

The tool's `condensation_edges` deduplicate multi-edge inter-component links into unique pairs `(from, to)`. Downstream nodes such as 'publish' and 'notify' remain acyclic singletons, illustrating that dependency propagation outside a cycle does not inherit the cyclic flag.

Sources and further reading