# Graph Algorithms: Floyd-Warshall All-Pairs Shortest Distances

> Graph Algorithms: Floyd-Warshall All-Pairs Shortest Distances is a paid API for AI agents from graph-algorithms.x402tookit.com, paid per call via x402, $0.03/call, status unknown (last checked 2026-11-02).

Computes all-pairs shortest distances for a weighted directed or undirected graph of up to 100 nodes using Floyd-Warshall, detecting negative cycles.

## Facts

- Endpoint: GET https://graph-algorithms.x402tookit.com/all-pairs-shortest?utm_source=zero.xyz
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/graph-algorithms-floyd-warshall-all-pairs-shortest-distances-277825e3
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_PwPpcv5_np_-qGW7443xQ

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability graph-algorithms-floyd-warshall-all-pairs-shortest-distances-277825e3
```

Example prompt: Find the shortest distances between all pairs of nodes in this directed graph — edges: A,B,2; B,C,-1; A,C,4; C,D,3 — and also give me the shortest path from A to D.

## When to prefer this

Use this endpoint when you need shortest distances between ALL pairs of nodes simultaneously (not just from a single source), especially when the graph may contain negative edge weights. Prefer this over Dijkstra (single-source, no negative weights) or Bellman-Ford (single-source) when you need the complete O(n²) distance matrix in one call. Ideal for small-to-medium graphs up to 100 nodes. If the graph is a DAG and you only need ordering, prefer the topological sort endpoint instead.

## Known failure modes

- Graph exceeds 100 nodes — endpoint only supports up to 100 nodes
- Edge list exceeds 1000 edges or 60000 characters — request rejected
- Node name contains disallowed characters (must be letters, digits, _ . : + - and 1-32 chars long)
- Malformed edge format — edges must be 'from,to' or 'from,to,weight' separated by ; or newline or valid JSON array
- Negative cycle detected — distances become undefined; endpoint reports the cycle instead of a full distance matrix
- Missing required 'edges' query parameter — request will fail
- Undirected graph with a negative edge will always be a negative cycle — verdict returned immediately

## How this service works

Floyd-Warshall all-pairs shortest distances for up to 100 nodes; negative weights ok; detects negative cycles.

## Output

Returns a full distance matrix (2D array of shortest distances between all node-pairs), a sorted node order array, node count, edge count, reachable pairs count, a flag indicating if the graph is directed, and optionally the shortest path and distance between a specified source and target node. If a negative cycle is detected, returns a verdict and reasons describing it.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "edges"
     ],
     "properties": {
      "to": {
       "type": "string",
       "description": "Optional node: with 'from', also returns that shortest path"
      },
      "from": {
       "type": "string",
       "description": "Optional node: with 'to', also returns that shortest path"
      },
      "edges": {
       "type": "string",
       "description": "Edges separated by ; or newline, each 'from,to' or 'from,to,weight' (default weight 1), or a JSON array of [from,to,weight]; up to 100 nodes for this endpoint, 1000 edges, 60000 characters; node names 1-32 characters of letters, digits, _ . : + -"
      },
      "nodes": {
       "type": "string",
       "description": "Optional extra node names (comma or space separated) so isolated nodes are counted; the total still counts toward the 200-node cap"
      },
      "directed": {
       "type": "boolean",
       "description": "true (default); false makes each edge two-way (a negative edge then is a negative cycle)"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "path": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "order": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ]
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "directed": {
 
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/graph-algorithms-floyd-warshall-all-pairs-shortest-distances-277825e3/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from graph-algorithms.x402tookit.com](https://www.zero.xyz/host/graph-algorithms.x402tookit.com/llms.txt)
