Graph find cycle

graph-find-cycle · version 1.0.0 · Graphs & scheduling · free, no key needed

Find one directed cycle by 3-color DFS, or report that the graph is acyclic.

Use when you need to: graph find cycle · find a directed cycle · report one directed cycle.

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "nodes": [
    "a",
    "b",
    "c"
  ],
  "edges": [
    {
      "from": "a",
      "to": "b"
    },
    {
      "from": "b",
      "to": "c"
    },
    {
      "from": "c",
      "to": "a"
    }
  ]
}

Response:

{
  "result": {
    "cyclic": true,
    "cycle": [
      "a",
      "b",
      "c",
      "a"
    ]
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "graph-find-cycle",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "a",
      "b",
      "c"
    ],
    "edges": [
      {
        "from": "a",
        "to": "b"
      },
      {
        "from": "b",
        "to": "c"
      },
      {
        "from": "c",
        "to": "a"
      }
    ]
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/graph-find-cycle/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["a","b","c"],"edges":[{"from":"a","to":"b"},{"from":"b","to":"c"},{"from":"c","to":"a"}]}'

The machine-readable contract is at /v1/tools/graph-find-cycle/versions/1.0.0.

CLI

node cli.mjs run graph-find-cycle 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.