Graph reverse
graph-reverse · version 1.0.0 · Graphs & scheduling · free, no key needed
Reverse every directed edge of a simple graph, keeping node order and original edge order.
Use when you need to: graph reverse · reverse every directed edge · transpose a directed graph.
Supported
- graph reverse
- reverse every directed edge
- transpose a directed graph
Not supported
- reversing a subset of edges
- transpose of adjacency matrix export
- undirected reverse
- weighted edge reverse
Behavior
- Input is a directed simple graph with unique node ids and unique (from, to) edges.
- Output nodes is the input node array unchanged, including declared order.
- Each output edge is {from: old.to, to: old.from} in the original declared edge order.
- Self-loops stay as self-loops.
- Cycles are allowed; this tool does not reject them.
- The reverse remains a simple graph because the original already forbade duplicate (from, to) pairs.
Input
nodes(array of string, required): max items 2000; each min length 1; each max length 256edges(array of object, required): max items 10000
Output
nodes(array of string, required): max items 2000; each min length 1; each max length 256edges(array of object, required): max items 10000
Limits
- max nodes: 2000
- max edges: 10000
- max node id bytes: 256
Example
Request input:
{
"nodes": [
"build",
"test",
"deploy"
],
"edges": [
{
"from": "build",
"to": "test"
},
{
"from": "test",
"to": "deploy"
},
{
"from": "build",
"to": "deploy"
}
]
}
Response:
{
"result": {
"nodes": [
"build",
"test",
"deploy"
],
"edges": [
{
"from": "test",
"to": "build"
},
{
"from": "deploy",
"to": "test"
},
{
"from": "deploy",
"to": "build"
}
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "graph-reverse",
"version": "1.0.0",
"input": {
"nodes": [
"build",
"test",
"deploy"
],
"edges": [
{
"from": "build",
"to": "test"
},
{
"from": "test",
"to": "deploy"
},
{
"from": "build",
"to": "deploy"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/graph-reverse/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"nodes":["build","test","deploy"],"edges":[{"from":"build","to":"test"},{"from":"test","to":"deploy"},{"from":"build","to":"deploy"}]}'
The machine-readable contract is at /v1/tools/graph-reverse/versions/1.0.0.
CLI
node cli.mjs run graph-reverse 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Graph find cycle: Find one directed cycle by 3-color DFS, or report that the graph is acyclic.
- Graph connected components: Partition a directed simple graph into undirected connected components, ignoring edge direction.
- Graph DAG longest path: Return a longest node-weighted path in a DAG, where path weight is the sum of node durations.
- Graph induced subgraph: Return the vertex-induced subgraph on a listed node subset, preserving declared node and edge order.
- Graph reachable from: List nodes reachable from given sources by directed BFS, in discovery order.
- Graph shortest unweighted path: Find a shortest directed path by fewest edges from source to target.