# Graph transitive reduction

`graph-transitive-reduction` · version 1.0.0 · Graphs & scheduling · free, no key needed

Compute the transitive reduction of a DAG: keep an edge u→v iff the original graph has no directed path from u to v of length at least 2.

**Use when you need to: graph transitive reduction · DAG transitive reduction · remove redundant DAG edges.**

## Supported

- graph transitive reduction
- DAG transitive reduction
- remove redundant DAG edges

## Not supported

- reduction of cyclic graphs
- undirected transitive reduction
- minimum equivalent graph on cycles
- counting paths

## Behavior

- Input is a directed simple graph that must be a DAG; self-loops and other cycles throw invalid_input with a message containing cycle.
- Output nodes is the input node array in declared order.
- A directed edge u→v is kept iff the original graph has no directed path from u to v of length at least 2.
- Kept edges appear in original declared edge order.
- Empty graph {nodes:[], edges:[]} is unchanged.
- Reachability is directed; this is not an undirected reduction.

## Input

- `nodes` (array of string, required): max items 2000; each min length 1; each max length 256
- `edges` (array of object, required): max items 10000

## Output

- `nodes` (array of string, required): max items 2000; each min length 1; each max length 256
- `edges` (array of object, required): max items 10000

## Limits

- max nodes: 2000
- max edges: 10000
- max node id bytes: 256

## Example

Request input:

```json
{
  "nodes": [
    "build",
    "test",
    "deploy"
  ],
  "edges": [
    {
      "from": "build",
      "to": "test"
    },
    {
      "from": "test",
      "to": "deploy"
    },
    {
      "from": "build",
      "to": "deploy"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "nodes": [
      "build",
      "test",
      "deploy"
    ],
    "edges": [
      {
        "from": "build",
        "to": "test"
      },
      {
        "from": "test",
        "to": "deploy"
      }
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "graph-transitive-reduction",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "build",
      "test",
      "deploy"
    ],
    "edges": [
      {
        "from": "build",
        "to": "test"
      },
      {
        "from": "test",
        "to": "deploy"
      },
      {
        "from": "build",
        "to": "deploy"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/graph-transitive-reduction/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["build","test","deploy"],"edges":[{"from":"build","to":"test"},{"from":"test","to":"deploy"},{"from":"build","to":"deploy"}]}'
```

The machine-readable contract is at [/v1/tools/graph-transitive-reduction/versions/1.0.0](/v1/tools/graph-transitive-reduction/versions/1.0.0).

### CLI

```sh
node cli.mjs run graph-transitive-reduction 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Graph DAG longest path](/tools/graph-dag-longest-path): Return a longest node-weighted path in a DAG, where path weight is the sum of node durations.
- [Graph shortest unweighted path](/tools/graph-shortest-unweighted-path): Find a shortest directed path by fewest edges from source to target.
- [Graph topological sort](/tools/graph-topological-sort): Return a Kahn topological order of a directed acyclic graph, breaking ready-set ties by declared node index.
- [Graph transitive closure](/tools/graph-transitive-closure): List directed reachability pairs of path length at least 1, ordered by declared node index.
- [Graph ancestors](/tools/graph-ancestors): List every ancestor of given targets, including the targets, in reverse-graph BFS discovery order.
- [Graph connected components](/tools/graph-connected-components): Partition a directed simple graph into undirected connected components, ignoring edge direction.
