Spanning tree weight check

spanning-tree-weight-check · version 1.0.0 · Numbers & math · free, no key needed

Check that claimed edge IDs form a spanning tree and that their exact total weight equals the claimed weight.

Use when you need to: check spanning tree total weight · verify claimed tree cost · sum weights of tree edges exactly.

Decide before calling

Read the versioned contract and the supported scope below. Reuse spanning-tree-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 spanning-tree-weight-check@1.0.0 for check spanning tree total weight. 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": [
      "x",
      "y",
      "z"
    ],
    "edges": [
      {
        "id": "xy",
        "u": "x",
        "v": "y",
        "weight": "-2"
      },
      {
        "id": "yz",
        "u": "y",
        "v": "z",
        "weight": "15"
      },
      {
        "id": "xz",
        "u": "x",
        "v": "z",
        "weight": "40"
      }
    ]
  },
  "tree_edge_ids": [
    "xy",
    "yz"
  ],
  "claimed_weight": "13"
}

Response:

{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "tree_weight": "13",
    "reference_version": "clrs-4e-2022-ch21-minimum-spanning-trees"
  }
}

How to call it

MCP

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

{
  "id": "spanning-tree-weight-check",
  "version": "1.0.0",
  "input": {
    "graph": {
      "vertices": [
        "x",
        "y",
        "z"
      ],
      "edges": [
        {
          "id": "xy",
          "u": "x",
          "v": "y",
          "weight": "-2"
        },
        {
          "id": "yz",
          "u": "y",
          "v": "z",
          "weight": "15"
        },
        {
          "id": "xz",
          "u": "x",
          "v": "z",
          "weight": "40"
        }
      ]
    },
    "tree_edge_ids": [
      "xy",
      "yz"
    ],
    "claimed_weight": "13"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/spanning-tree-weight-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"graph":{"vertices":["x","y","z"],"edges":[{"id":"xy","u":"x","v":"y","weight":"-2"},{"id":"yz","u":"y","v":"z","weight":"15"},{"id":"xz","u":"x","v":"z","weight":"40"}]},"tree_edge_ids":["xy","yz"],"claimed_weight":"13"}'

The machine-readable contract is at /v1/tools/spanning-tree-weight-check/versions/1.0.0.

CLI

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

Get the client at /clients/cli/.