# Graph reachable from

`graph-reachable-from` · version 1.0.0 · Graphs & scheduling · free, no key needed

List nodes reachable from given sources by directed BFS, in discovery order.

**Use when you need to: graph reachable from · directed reachability from sources · bfs reachable nodes from sources.**

## Supported

- graph reachable from
- directed reachability from sources
- bfs reachable nodes from sources

## Not supported

- depth-limited search as a heuristic
- undirected reachability
- ancestors or upstream reachability
- shortest path
- weighted reachability

## Behavior

- BFS follows directed edges from the given sources.
- sources is a non-empty array of unique node ids that exist in nodes.
- Enqueue sources in the given sources array order, skipping an id already queued.
- Pop the front of the queue, then push unseen outgoing neighbors in declared edge order.
- A node is listed once, at first enqueue. Output order is that discovery order.
- Every source is included even if it has no outgoing edges.
- An empty graph cannot name a source and is rejected.
- Self-loops and cycles do not add a node twice and do not follow reverse edges.
- Unknown input fields, duplicate nodes or edges, and missing endpoints 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
- `sources` (array of string, required): min items 1; max items 2000; each min length 1; each max length 256

## Output

- `nodes` (array of string, required)

## Limits

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

## Example

Request input:

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

Response:

```json
{
  "result": {
    "nodes": [
      "build",
      "test",
      "deploy",
      "cover"
    ]
  }
}
```

## How to call it

### MCP

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

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

### HTTP (no key)

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

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

### CLI

```sh
node cli.mjs run graph-reachable-from 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.
- [Graph transitive closure](/tools/graph-transitive-closure): List directed reachability pairs of path length at least 1, ordered by declared node index.
- [Graph validate](/tools/graph-validate): Inspect a well-formed directed simple graph and report counts, isolated nodes, and maximum degrees.
- [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.
- [Graph find cycle](/tools/graph-find-cycle): Find one directed cycle by 3-color DFS, or report that the graph is acyclic.
