Skip to main content

REST API Reference

The Rocket HTTP server runs on the mpi-master container and listens on port 8000.

Base URL: http://localhost:8000

Endpoints

GET /health

Health check endpoint.

Response:

{ "status": "ok" }

GET /mpi_status

Returns MPI cluster information.

Response:

{
"mpi_processes": 2,
"mpi_mode": "distributed",
"connectivity": "master connected to 1 worker(s)"
}

POST /process_file

Accepts a graph file and algorithm configuration, distributes computation via MPI, and returns results.

Content-Type: multipart/form-data

Form Fields:

FieldTypeDescription
fileFileGraph file (edge list or adjacency list)
requestJSON stringAlgorithm configuration

Request JSON Schema:

{
"algorithm": "dijkstra",
"file_format": "edge_list",
"start_node": 0,
"end_node": 4
}
FieldTypeRequiredValues
algorithmstringYesSee algorithm list below
file_formatstringYes"edge_list" | "adjacency_list"
start_nodeintegerConditionalRequired for BFS, DFS, Dijkstra, A*, Bellman-Ford
end_nodeintegerConditionalRequired for A* only

Algorithm Values:

ValueAlgorithm
"bfs"Breadth-First Search
"dfs"Depth-First Search
"dijkstra"Dijkstra's Shortest Path
"astar"A* Shortest Path
"bellman_ford"Bellman-Ford
"kruskal"Kruskal's MST
"pagerank"PageRank
"scc"Strongly Connected Components
"topological_sort"Topological Sort

Response — Traversal / Shortest Path:

{
"path": [0, 2, 3, 4],
"distances": { "0": 0.0, "2": 1.0, "3": 1.5, "4": 3.5 },
"has_negative_cycle": false,
"mpi_processes": 2,
"mpi_mode": "distributed"
}

Response — PageRank:

{
"pagerank": { "0": 0.152, "1": 0.387 },
"mpi_processes": 2,
"mpi_mode": "distributed"
}

Response — SCC:

{
"scc": [[0, 1, 2], [3, 4], [5]],
"mpi_processes": 2,
"mpi_mode": "distributed"
}

Response — MST (Kruskal):

{
"path": [0, 2, 2, 3, 3, 4, 0, 1],
"mpi_processes": 2,
"mpi_mode": "distributed"
}

MST path is interleaved [u0, v0, u1, v1, ...] edge pairs.

Example:

curl -X POST http://localhost:8000/process_file \
-F "file=@graph.txt" \
-F 'request={"algorithm":"dijkstra","file_format":"edge_list","start_node":0}'

POST /graph_metrics

Computes structural graph metrics. Runs entirely on the master node (no MPI).

Content-Type: multipart/form-data

Form Fields:

FieldTypeDescription
fileFileGraph file
requestJSON string{"file_format": "edge_list"}

Response:

{
"node_count": 5,
"edge_count": 7,
"density": 0.35,
"connected_components": 1,
"is_dag": false,
"avg_out_degree": 1.4,
"top_hubs": [
{ "node": 1, "degree": 3 },
{ "node": 0, "degree": 2 }
]
}

Example:

curl -X POST http://localhost:8000/graph_metrics \
-F "file=@graph.txt" \
-F 'request={"file_format":"edge_list"}'

OPTIONS /*

CORS preflight handler. Returns appropriate headers for browser cross-origin requests.

Error Responses

{
"error": "Failed to parse graph file: invalid format on line 3"
}

HTTP status codes:

  • 200 — Success
  • 400 — Bad request (invalid file or algorithm config)
  • 500 — Server error (MPI failure, algorithm error)