Graph path weight check

graph-path-weight-check · version 1.0.0 · Numbers & math · free, no key needed

Check that a path of edge IDs walks source to target in a weighted digraph and sums to the claimed exact weight.

Use when you need to: check path weight in weighted graph · verify claimed route cost · does this path exist in the directed graph.

Decide before calling

Read the versioned contract and the supported scope below. Reuse graph-path-weight-check@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use graph-path-weight-check@1.0.0 for check path weight in weighted graph. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "graph": {
    "vertices": [
      "s",
      "y",
      "t",
      "x"
    ],
    "edges": [
      {
        "id": "sy",
        "from": "s",
        "to": "y",
        "weight": "5"
      },
      {
        "id": "yt",
        "from": "y",
        "to": "t",
        "weight": "3"
      },
      {
        "id": "tx",
        "from": "t",
        "to": "x",
        "weight": "1"
      }
    ]
  },
  "source": "s",
  "target": "x",
  "path_edge_ids": [
    "sy",
    "yt",
    "tx"
  ],
  "claimed_weight": "9"
}

Response:

{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "path_weight": "9",
    "path_edge_count": 3,
    "reference_version": "clrs-4e-2022-ch22-single-source-shortest-paths"
  }
}

How to call it

MCP

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

{
  "id": "graph-path-weight-check",
  "version": "1.0.0",
  "input": {
    "graph": {
      "vertices": [
        "s",
        "y",
        "t",
        "x"
      ],
      "edges": [
        {
          "id": "sy",
          "from": "s",
          "to": "y",
          "weight": "5"
        },
        {
          "id": "yt",
          "from": "y",
          "to": "t",
          "weight": "3"
        },
        {
          "id": "tx",
          "from": "t",
          "to": "x",
          "weight": "1"
        }
      ]
    },
    "source": "s",
    "target": "x",
    "path_edge_ids": [
      "sy",
      "yt",
      "tx"
    ],
    "claimed_weight": "9"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/graph-path-weight-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"graph":{"vertices":["s","y","t","x"],"edges":[{"id":"sy","from":"s","to":"y","weight":"5"},{"id":"yt","from":"y","to":"t","weight":"3"},{"id":"tx","from":"t","to":"x","weight":"1"}]},"source":"s","target":"x","path_edge_ids":["sy","yt","tx"],"claimed_weight":"9"}'

The machine-readable contract is at /v1/tools/graph-path-weight-check/versions/1.0.0.

CLI

node cli.mjs run graph-path-weight-check 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.