# Schedule critical path

`schedule-critical-path` · version 1.0.0 · Graphs & scheduling · free, no key needed

Compute CPM zero-slack critical nodes and tight edges on a DAG, plus one representative critical path.

**Use when you need to: schedule critical path · cpm zero-slack critical path · critical nodes edges and representative path.**

## Supported

- schedule critical path
- cpm zero-slack critical path
- critical nodes edges and representative path

## Not supported

- multiple enumerated critical paths
- probabilistic PERT
- crashing
- calendar dates and working hours

## Behavior

- Input is a directed simple graph plus durations whose own keys are exactly the node ids, each a canonical non-negative integer string of at most 18 digits.
- Edge from→to is finish-to-start with lag 0: to cannot start before from finishes.
- The graph must be a DAG under Kahn order (smallest remaining indegree-0 declared index); a cycle including a self-loop throws invalid_input with a message containing cycle.
- ES[v] is 0 if v has no predecessors, else the maximum EF of its predecessors. EF[v] is ES[v] plus duration[v]. Times that exceed 18 digits throw.
- makespan is the maximum EF, or 0 when there are no nodes.
- Latest times walk the Kahn sequence backwards: LF[v] is makespan if v has no successors, else the minimum LS of its successors. LS[v] is LF[v] minus duration[v].
- Slack is LS minus ES (equal to LF minus EF). A node is critical iff its slack is 0.
- critical_nodes lists slack-0 ids in declared nodes order.
- critical_edges lists original edges in original edge order whose both ends are critical and EF[from] equals ES[to].
- The representative path is empty on the empty graph. Otherwise it starts at the smallest-index critical node with no incoming critical tight edge, then repeatedly appends the smallest-index successor reached by a critical tight edge.

## 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
- `durations` (object, required)

## Output

- `makespan` (string, required): max length 18; pattern `^(0|[1-9][0-9]*)$`
- `critical_nodes` (array of string, required): max items 2000; each min length 1; each max length 256
- `critical_edges` (array of object, required): max items 10000
- `path` (array of string, required): max items 2000; each min length 1; each max length 256

## Limits

- max nodes: 2000
- max edges: 10000
- max node id bytes: 256
- max duration digits: 18

## Example

Request input:

```json
{
  "nodes": [
    "spec",
    "api",
    "ui",
    "integ",
    "ship"
  ],
  "edges": [
    {
      "from": "spec",
      "to": "api"
    },
    {
      "from": "spec",
      "to": "ui"
    },
    {
      "from": "api",
      "to": "integ"
    },
    {
      "from": "ui",
      "to": "integ"
    },
    {
      "from": "integ",
      "to": "ship"
    }
  ],
  "durations": {
    "spec": "2",
    "api": "5",
    "ui": "3",
    "integ": "4",
    "ship": "1"
  }
}
```

Response:

```json
{
  "result": {
    "makespan": "12",
    "critical_nodes": [
      "spec",
      "api",
      "integ",
      "ship"
    ],
    "critical_edges": [
      {
        "from": "spec",
        "to": "api"
      },
      {
        "from": "api",
        "to": "integ"
      },
      {
        "from": "integ",
        "to": "ship"
      }
    ],
    "path": [
      "spec",
      "api",
      "integ",
      "ship"
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "schedule-critical-path",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "spec",
      "api",
      "ui",
      "integ",
      "ship"
    ],
    "edges": [
      {
        "from": "spec",
        "to": "api"
      },
      {
        "from": "spec",
        "to": "ui"
      },
      {
        "from": "api",
        "to": "integ"
      },
      {
        "from": "ui",
        "to": "integ"
      },
      {
        "from": "integ",
        "to": "ship"
      }
    ],
    "durations": {
      "spec": "2",
      "api": "5",
      "ui": "3",
      "integ": "4",
      "ship": "1"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/schedule-critical-path/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["spec","api","ui","integ","ship"],"edges":[{"from":"spec","to":"api"},{"from":"spec","to":"ui"},{"from":"api","to":"integ"},{"from":"ui","to":"integ"},{"from":"integ","to":"ship"}],"durations":{"spec":"2","api":"5","ui":"3","integ":"4","ship":"1"}}'
```

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

### CLI

```sh
node cli.mjs run schedule-critical-path 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Graph shortest unweighted path](/tools/graph-shortest-unweighted-path): Find a shortest directed path by fewest edges from source to target.
- [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 validate](/tools/graph-validate): Inspect a well-formed directed simple graph and report counts, isolated nodes, and maximum degrees.
- [Schedule ready nodes](/tools/schedule-ready-nodes): List DAG nodes that can start because they are not completed and every predecessor is completed.
- [Graph ancestors](/tools/graph-ancestors): List every ancestor of given targets, including the targets, in reverse-graph BFS discovery order.
- [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.
