Catalog/workflow-topological-sort

Workflow

DAG topological sort API

Computes a valid execution order for a DAG via Kahn's algorithm (ties broken alphabetically for determinism) and throws if the graph has a cycle. Answers 'In what order can I run these dependent steps?', 'Is this dependency graph runnable?'.

Price$0.02per request
MethodPOST
Route/v1/workflow/topological-sort
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
topological-sortdagorderingdependenciesgraphkahnscheduleworkflow
API URLhttps://x402.hexl.dev/v1/workflow/topological-sort
Integration docs
Example request
{
  "nodes": [
    "a",
    "b",
    "c"
  ],
  "edges": [
    [
      "a",
      "b"
    ],
    [
      "b",
      "c"
    ]
  ]
}
Example response
{
  "order": [
    "a",
    "b",
    "c"
  ],
  "acyclic": true,
  "interpretation": "Valid execution order: a -> b -> c."
}
Input schema
{
  "type": "object",
  "required": [
    "nodes",
    "edges"
  ],
  "properties": {
    "nodes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "examples": [
        [
          "a",
          "b",
          "c"
        ]
      ]
    },
    "edges": {
      "type": "array",
      "description": "[from,to] pairs (from must precede to)",
      "examples": [
        [
          [
            "a",
            "b"
          ],
          [
            "b",
            "c"
          ]
        ]
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}