# Schedule ASAP layers

`schedule-asap-layers` · version 1.0.0 · Graphs & scheduling · free, no key needed

Partition a DAG into ASAP topological generations: each layer is the nodes that become ready together.

**Use when you need to: schedule asap layers · topological generations · ASAP depth layers of a DAG.**

## Supported

- schedule asap layers
- topological generations
- ASAP depth layers of a DAG

## Not supported

- ALAP layers
- processor counts
- node durations and earliest finish
- resource and capacity constraints

## Behavior

- Input is a directed simple graph { nodes, edges } parsed by the shared graph grammar.
- Edge from→to means from is a prerequisite of to and must complete before to starts.
- The graph must be a DAG; a cycle including a self-loop throws invalid_input with a message containing cycle.
- Layer 0 is every node with indegree 0, listed in declared node-index order.
- Each later layer is the nodes whose remaining indegree hits 0 when the previous layer is removed, listed in declared index order.
- Equivalently, a node is in layer k iff every predecessor is in an earlier layer and at least one predecessor is in layer k-1 (sources have no predecessors).
- The empty graph returns { layers: [] }. Isolated nodes share one layer in declared index order.
- Unknown fields, duplicate node ids, duplicate directed pairs, missing endpoints, and oversize graphs are rejected.

## 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

- `layers` (array of array of string, required): max items 2000; each max items 2000; each each min length 1; each each max length 256

## Limits

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

## Example

Request input:

```json
{
  "nodes": [
    "fetch",
    "compile",
    "lint",
    "link",
    "docs"
  ],
  "edges": [
    {
      "from": "fetch",
      "to": "compile"
    },
    {
      "from": "fetch",
      "to": "lint"
    },
    {
      "from": "compile",
      "to": "link"
    },
    {
      "from": "lint",
      "to": "link"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "layers": [
      [
        "fetch",
        "docs"
      ],
      [
        "compile",
        "lint"
      ],
      [
        "link"
      ]
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "schedule-asap-layers",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "fetch",
      "compile",
      "lint",
      "link",
      "docs"
    ],
    "edges": [
      {
        "from": "fetch",
        "to": "compile"
      },
      {
        "from": "fetch",
        "to": "lint"
      },
      {
        "from": "compile",
        "to": "link"
      },
      {
        "from": "lint",
        "to": "link"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/schedule-asap-layers/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["fetch","compile","lint","link","docs"],"edges":[{"from":"fetch","to":"compile"},{"from":"fetch","to":"lint"},{"from":"compile","to":"link"},{"from":"lint","to":"link"}]}'
```

The machine-readable contract is at [/v1/tools/schedule-asap-layers/versions/1.0.0](/v1/tools/schedule-asap-layers/versions/1.0.0).

### CLI

```sh
node cli.mjs run schedule-asap-layers 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 induced subgraph](/tools/graph-induced-subgraph): Return the vertex-induced subgraph on a listed node subset, preserving declared node and edge order.
- [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.
- [Schedule earliest finish](/tools/schedule-earliest-finish): Compute CPM earliest start and earliest finish times for a DAG with node durations, plus the project makespan.
- [Graph ancestors](/tools/graph-ancestors): List every ancestor of given targets, including the targets, in reverse-graph BFS discovery order.
- [Graph dependency impact](/tools/graph-dependency-impact): List nodes downstream of a removed set: not themselves removed, reachable by a directed path of length at least 1.
