# Coloring validity check

`coloring-validity-check` · version 1.0.0 · Numbers & math · free, no key needed

Check an indexed graph coloring certificate and report the first uncovered vertex or monochromatic edge.

**Use when you need to: check graph coloring validity · validate a vertex color assignment · find first coloring conflict.**

## Decide before calling

Read the [versioned contract](/v1/tools/coloring-validity-check/versions/1.0.0) and the supported scope below. Reuse `coloring-validity-check@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `coloring-validity-check@1.0.0` for check graph coloring validity. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- check graph coloring validity
- validate a vertex color assignment
- find first coloring conflict
- check proper graph coloring certificate
- verify every vertex has a color
- test claimed graph coloring

## Not supported

- finding or repairing a coloring
- computing the chromatic number
- accepting endpoint names instead of indices

## Behavior

- Vertices are the indices 0 through vertex_count-1; edges are inspected in supplied array order.
- A proper coloring assigns one non-null, non-empty exact Unicode string to every vertex and gives adjacent endpoints unequal strings.
- Color equality is exact JavaScript string equality; no normalization, case folding, trimming, or color renaming occurs.
- Every verdict names Diestel Graph Theory 5th ed. (2017), sections 1.6 and 5.2; duplicates are checked in place and a self-loop necessarily conflicts.
- A false verdict reports coverage discrepancies before edge discrepancies; ties use ascending vertex or edge index.

## Input

- `vertex_count` (integer, required): min 0; max 10000
- `edges` (array of object, required): max items 50000
- `colors` (array of string or null, required): max items 10000; each max length 64

## Output

- `valid` (boolean, required)
- `reason` (string, optional)
- `discrepancy` (object, optional)
- `reference_version` (string, required)

## Limits

- max vertices: 10000
- max edges: 50000
- max color bytes: 64

## Example

Request input:

```json
{
  "vertex_count": 3,
  "edges": [
    {
      "from": 0,
      "to": 1
    },
    {
      "from": 1,
      "to": 2
    }
  ],
  "colors": [
    "red",
    "blue",
    "red"
  ]
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reference_version": "Diestel Graph Theory 5th ed. (2017), sections 1.6 and 5.2"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "coloring-validity-check",
  "version": "1.0.0",
  "input": {
    "vertex_count": 3,
    "edges": [
      {
        "from": 0,
        "to": 1
      },
      {
        "from": 1,
        "to": 2
      }
    ],
    "colors": [
      "red",
      "blue",
      "red"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/coloring-validity-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"vertex_count":3,"edges":[{"from":0,"to":1},{"from":1,"to":2}],"colors":["red","blue","red"]}'
```

The machine-readable contract is at [/v1/tools/coloring-validity-check/versions/1.0.0](/v1/tools/coloring-validity-check/versions/1.0.0).

### CLI

```sh
node cli.mjs run coloring-validity-check 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Bipartite coloring check](/tools/bipartite-coloring-check): Check a complete 0/1 coloring witness for graph bipartiteness and report the first certificate discrepancy.
- [Graph coloring check](/tools/graph-coloring-check): Check that a node colouring of an undirected graph is proper (and within k colours); returns the first conflict.
- [Network flow feasibility check](/tools/network-flow-feasibility-check): Check a claimed s-t flow for capacity bounds and conservation with exact integers; returns the first bad edge or node.
- [Coloring count check](/tools/coloring-count-check): Check a proper indexed coloring and an exact canonical-decimal claim for its number of distinct colors.
- [Spanning tree structure check](/tools/spanning-tree-structure-check): Check that claimed edge IDs form a spanning tree of a graph; reports the first missing, repeated or cyclic edge
- [Chromatic certificate check](/tools/chromatic-certificate-check): Check a claim chi(G) = k: a proper k-colouring plus a clique or bounded exhaustive proof; returns the first discrepancy.
