Graph transitive closure
graph-transitive-closure · version 1.0.0 · Graphs & scheduling · free, no key needed
List directed reachability pairs of path length at least 1, ordered by declared node index.
Use when you need to: graph transitive closure · directed reachability pairs · positive-length reachability pairs.
Supported
- graph transitive closure
- directed reachability pairs
- positive-length reachability pairs
Not supported
- counting paths
- reflexive closure option
- undirected closure
- reachability from named sources
Behavior
- Input is a directed simple graph with unique node ids and unique from-to edges.
- Each output pair (from, to) means a directed walk of length at least 1 exists from from to to.
- A pair (v, v) is included only when a positive-length directed cycle returns to v, including a self-loop.
- Trivial reflexive pairs are omitted when no such cycle exists.
- Pairs are ordered by increasing declared from index, then increasing declared to index. Ids are not sorted lexicographically.
- An empty graph or a graph with no edges returns an empty pairs array.
- More than 500 nodes is rejected. More than 50000 pairs is rejected.
- Self-loops and longer cycles are allowed. This operation does not count paths or ignore edge direction.
Input
nodes(array of string, required): max items 500; each min length 1; each max length 256edges(array of object, required): max items 10000
Output
pairs(array of object, required): max items 50000
Limits
- max nodes: 500
- max edges: 10000
- max node id bytes: 256
- max pairs: 50000
Example
Request input:
{
"nodes": [
"build",
"test",
"package",
"deploy"
],
"edges": [
{
"from": "build",
"to": "test"
},
{
"from": "test",
"to": "package"
},
{
"from": "package",
"to": "deploy"
},
{
"from": "build",
"to": "package"
}
]
}
Response:
{
"result": {
"pairs": [
{
"from": "build",
"to": "test"
},
{
"from": "build",
"to": "package"
},
{
"from": "build",
"to": "deploy"
},
{
"from": "test",
"to": "package"
},
{
"from": "test",
"to": "deploy"
},
{
"from": "package",
"to": "deploy"
}
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "graph-transitive-closure",
"version": "1.0.0",
"input": {
"nodes": [
"build",
"test",
"package",
"deploy"
],
"edges": [
{
"from": "build",
"to": "test"
},
{
"from": "test",
"to": "package"
},
{
"from": "package",
"to": "deploy"
},
{
"from": "build",
"to": "package"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/graph-transitive-closure/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"nodes":["build","test","package","deploy"],"edges":[{"from":"build","to":"test"},{"from":"test","to":"package"},{"from":"package","to":"deploy"},{"from":"build","to":"package"}]}'
The machine-readable contract is at /v1/tools/graph-transitive-closure/versions/1.0.0.
CLI
node cli.mjs run graph-transitive-closure 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Graph reachable from: List nodes reachable from given sources by directed BFS, in discovery order.
- Graph find cycle: Find one directed cycle by 3-color DFS, or report that the graph is acyclic.
- Graph reverse: Reverse every directed edge of a simple graph, keeping node order and original edge order.
- Graph shortest unweighted path: Find a shortest directed path by fewest edges from source to target.
- Graph strongly connected components: Partition a directed simple graph into strongly connected components, listed by declared node index.
- Graph to adjacency: Convert a directed simple graph into per-node outgoing adjacency lists.