# Graph connected components

`graph-connected-components` · version 1.0.0 · Graphs & scheduling · free, no key needed

Partition a directed simple graph into undirected connected components, ignoring edge direction.

**Use when you need to: graph connected components · undirected connected components · connected components ignoring edge direction.**

## Supported

- graph connected components
- undirected connected components
- connected components ignoring edge direction

## Not supported

- strongly connected components
- community detection
- directed weak and strong mixed partition
- undirected input mode flag

## Behavior

- Input is a directed simple graph { nodes, edges } parsed by the shared graph grammar.
- Connectivity ignores edge direction: from→to and to→from join the same component.
- A self-loop does not connect two distinct nodes.
- Each component lists member ids in declared node-index order.
- Components are ordered by the smallest declared index among their members.
- Isolated nodes, including nodes that have only self-loops, are size-1 components.
- The empty graph returns { components: [] }.
- 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

- `components` (array of array of string, required)

## Limits

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

## Example

Request input:

```json
{
  "nodes": [
    "build",
    "lint",
    "docs",
    "deploy",
    "orphan"
  ],
  "edges": [
    {
      "from": "build",
      "to": "lint"
    },
    {
      "from": "lint",
      "to": "deploy"
    },
    {
      "from": "docs",
      "to": "deploy"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "components": [
      [
        "build",
        "lint",
        "docs",
        "deploy"
      ],
      [
        "orphan"
      ]
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "graph-connected-components",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "build",
      "lint",
      "docs",
      "deploy",
      "orphan"
    ],
    "edges": [
      {
        "from": "build",
        "to": "lint"
      },
      {
        "from": "lint",
        "to": "deploy"
      },
      {
        "from": "docs",
        "to": "deploy"
      }
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Graph strongly connected components](/tools/graph-strongly-connected-components): Partition a directed simple graph into strongly connected components, listed by declared node index.
- [Graph reverse](/tools/graph-reverse): Reverse every directed edge of a simple graph, keeping node order and original edge order.
- [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.
- [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.
