This document lists all available routes in the Graph HTTP server and demonstrates how to use them via curl.
- Graph ID (
id) is assigned by the server upon graph creation. - Directionality (
bi) and Weight flag (weighed) are held by the client. The server does not store this metadata. - Deletion must be handled explicitly by the caller (
/graph/destroy?id=...); mass deletion is not allowed to prevent unintentional interruption. - Server will clean up all graphs on shutdown.
- The
/page is a minimal REPL-like demo, not suitable for production use. Consider usingPythonorNode.jsfor robust clients.
- Method:
GET - Description: Health check
Example:
curl -X GET http://localhost:8080/pingResponse:
{"status": "alive"}- Method:
POST - Description: Gracefully shuts down the server
Example:
curl -X POST http://localhost:8080/shutdown_serverResponse:
{"status": "server_shutdown_requested"}- Method:
POST - Body:
application/json
{ "size": 100 }Example:
curl -X POST http://localhost:8080/graph/create \
-H "Content-Type: application/json" \
-d '{"size":100}'Response:
{ "id": 1 }- Method:
GET - Query Parameter:
id
Example:
curl -X GET "http://localhost:8080/graph/exists?id=1"Response:
{ "exists": true }- Method:
POST - Body:
application/json
{
"id": 1,
"u": 0,
"v": 1,
"weight": 10,
"bi": true
}Example:
curl -X POST http://localhost:8080/graph/add-edge \
-H "Content-Type: application/json" \
-d '{"id":1, "u":0, "v":1, "weight":10, "bi":true}'- Method:
POST - Body:
application/json
{
"id": 1,
"bi": false,
"lines": [
{ "u": 0, "v": 2, "weight": 3 },
{ "u": 1, "v": 2, "weight": 5 }
]
}Example:
curl -X POST http://localhost:8080/graph/batch-edges \
-H "Content-Type: application/json" \
-d '{"id":1,"bi":false,"lines":[{"u":0,"v":2,"weight":3},{"u":1,"v":2,"weight":5}]}'- Method:
GET - Query Parameters:
id,node,directed
Example:
curl -X GET "http://localhost:8080/graph/degree?id=1&node=0&directed=1"Response:
{ "in": 2, "out": 3 }- Method:
GET - Query Parameters:
id,directed
Example:
curl -X GET "http://localhost:8080/graph/degree_stats?id=1&directed=1"Response:
{
"min": 0,
"max": 6,
"density": 0.14,
"avg": 2.3
}- Method:
GET - Query Parameters:
id,directed
Example:
curl -X GET "http://localhost:8080/graph/isolated_nodes?id=1&directed=0"Response:
{ "nodes": [3, 5] }- Method:
GET - Query Parameters:
id,directed
Example:
curl -X GET "http://localhost:8080/graph/count_triangles?id=1&directed=1"Response:
{ "count": 8 }- Method:
GET - Query Parameters:
id,start,weighed
Example:
curl -X GET "http://localhost:8080/graph/shortest_path?id=1&start=0&weighed=1"Response:
{ "path": [0, 2, 5, 7] }- Method:
GET - Query Parameters:
id,weighed
Example:
curl -X GET "http://localhost:8080/graph/betweenness_centrality?id=1&weighed=0"Response:
{ "centrality": [0.1, 0.3, 0.0, 0.25] }-
Method:
GET -
Query Parameters:
id: Graph IDnode: Source node (0-based index)
-
Description: Returns all nodes that the specified
nodehas outgoing edges to — i.e., direct successors in a directed graph.This is equivalent to the "out-neighbors" of a node.
Example:
curl -X GET "http://localhost:8080/graph/get_from?id=1&node=2"Response:
{ "nodes": [3, 4, 7] }-
Method:
GET -
Query Parameters:
id: Graph IDnode: Target node (0-based index)
-
Description: Returns all nodes that have edges pointing to the specified
node— i.e., direct predecessors in a directed graph.This is equivalent to the "in-neighbors" of a node.
Example:
curl -X GET "http://localhost:8080/graph/get_to?id=1&node=2"Response:
{ "nodes": [0, 5] }-
Method:
GET -
Query Parameters:
id: Graph IDnode: Target node (0-based index)directed: Optional; set to1(default) for directed graphs or0for undirected graphs
-
Description: Returns the set of mutual neighbors of a node.
-
If
directed=1(default): Only nodes with both incoming and outgoing connections tonodeare returned. This is equivalent to the intersection of/graph/get_fromand/graph/get_to. -
If
directed=0: The server assumes the graph is undirected (edges are symmetric), and only checksnode → xfor neighbors.⚠️ The server does not enforce or verify symmetry — clients are responsible for maintaining undirected structure.
-
Example:
curl -X GET "http://localhost:8080/graph/get_neighbours?id=1&node=2&directed=1"Response:
{ "nodes": [3, 4] }| API | Meaning | Mode (directed) |
|---|---|---|
/graph/get_from |
Nodes node can reach (node → x) |
Directional |
/graph/get_to |
Nodes that can reach node (x → node) |
Directional |
/graph/get_neighbours |
Nodes where both node → x and x → node |
Directed (intersection of from + to) Or unilateral if directed=0 |
- Method:
DELETE - Query Parameter:
id
Example:
curl -X DELETE "http://localhost:8080/graph/destroy?id=1"Response:
{ "deleted": true }- Method:
GET - Description: List all active graph IDs
Example:
curl -X GET http://localhost:8080/graph/list_idsResponse:
{ "ids": [1, 2, 3] }