# Graph Algorithms: Bellman-Ford Shortest Paths

> Graph Algorithms: Bellman-Ford Shortest Paths is a paid API for AI agents from graph-algorithms.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-11-02).

Computes single-source shortest paths using the Bellman-Ford algorithm, supporting negative edge weights and detecting negative cycles reachable from the source.

## Facts

- Endpoint: GET https://graph-algorithms.x402tookit.com/bellman-ford?utm_source=zero.xyz
- Price: $0.02/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-bellman-ford-shortest-paths-f6969ee1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_7YhTEZQNsCUAa43eaw1e3

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-bellman-ford-shortest-paths-f6969ee1
```

Example prompt: Run a Bellman-Ford shortest path from node S to node T on this directed edge list: 'S,A,4; S,B,5; A,B,-3; B,T,2' — and let me know if there's a negative cycle reachable from S.

## When to prefer this

Choose this endpoint over Dijkstra when your graph contains negative edge weights, since Dijkstra does not support them. Prefer this over Floyd-Warshall when you need single-source shortest paths (not all-pairs) or your graph has more than 100 nodes. Use this specifically when you need to detect negative cycles reachable from a given source node, such as arbitrage detection in financial graphs or constraint satisfaction problems. If you only need all-pairs shortest paths on a small graph, Floyd-Warshall may be more appropriate.

## Known failure modes

- Source node not present in edge list — returns error indicating source not found
- Graph exceeds 200-node or 1000-edge limit — returns error with size constraints
- Negative cycle detected reachable from source — returns verdict indicating negative cycle rather than distances
- Malformed edge string (wrong format or invalid node names) — returns parse error
- Target node specified but unreachable — returns null path and infinite or null distance
- Edge weight parsing failure for non-numeric weights — returns validation error

## How this service works

Bellman-Ford shortest paths with negative weights; reports a negative cycle reachable from the source.

## Output

Returns a structured object including: a verdict (e.g. 'negative cycle detected' or 'path found'), a summary string, the shortest path as an ordered list of node names (if a target is given), total distance, hop count, a map of distances from the source to all reachable nodes, edge and node counts, whether the graph is directed, and any reasons or warnings. If a negative cycle reachable from the source is detected, the verdict and reasons fields indicate this clearly.

## 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",
      "source"
     ],
     "properties": {
      "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 200 nodes, 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"
      },
      "source": {
       "type": "string",
       "description": "Start node name; must appear in edges"
      },
      "target": {
       "type": "string",
       "description": "Optional end node; if given the path to it is returned"
      },
      "directed": {
       "type": "boolean",
       "description": "true (default); with false any negative edge is itself a negative cycle"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "hops": {
       "type": [
        "null",
        "number"
       ]
      },
      "path": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "target": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
      
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/graph-algorithms-bellman-ford-shortest-paths-f6969ee1/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)
