Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/cn/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [Rank](clients/restful-api/rank)
* [Variable](clients/restful-api/variable)
* [Graphs](clients/restful-api/graphs)
* [算法](clients/restful-api/algorithm)

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CN SUMMARY navigation uses English labels for all RESTful API entries; adding 算法 here is inconsistent with the established pattern in this file. Consider naming it Algorithm (matching the surrounding entries) unless you intend to localize the entire SUMMARY list.

Suggested change
* [算法](clients/restful-api/algorithm)
* [Algorithm](clients/restful-api/algorithm)

Copilot uses AI. Check for mistakes.
* [Task](clients/restful-api/task)
* [Gremlin](clients/restful-api/gremlin)
* [Cypher](clients/restful-api/cypher)
Expand Down
99 changes: 99 additions & 0 deletions content/cn/docs/clients/restful-api/algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: "算法 API"
linkTitle: "算法"
weight: 11
description: "算法任务 REST API:提交和监控异步图算法任务。"
---

### 6.1 算法

算法 API 允许提交长时间运行的图算法作为异步任务并跟踪其进度。

#### 6.1.1 提交算法任务

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as EN: weight: 11 duplicates content/cn/docs/clients/restful-api/variable.md (also weight 11), and the section numbering starts at 6.1 even though Graphs API already uses ### 6.1 (content/cn/docs/clients/restful-api/graphs.md:8). Please adjust weight and numbering to avoid collisions.

Suggested change
weight: 11
description: "算法任务 REST API:提交和监控异步图算法任务。"
---
### 6.1 算法
算法 API 允许提交长时间运行的图算法作为异步任务并跟踪其进度。
#### 6.1.1 提交算法任务
weight: 12
description: "算法任务 REST API:提交和监控异步图算法任务。"
---
### 6.2 算法
算法 API 允许提交长时间运行的图算法作为异步任务并跟踪其进度。
#### 6.2.1 提交算法任务

Copilot uses AI. Check for mistakes.

##### 方法与 URL

```
POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/jobs/algorithm/{algorithm_name}
```

对于旧版没有图空间的设置:
```
POST http://localhost:8080/graphs/{graph}/jobs/algorithm/{algorithm_name}
```
Comment thread
morningstarxcdcode marked this conversation as resolved.

##### 请求体

请求体因算法而异。常见参数包括:

- `max_iteration`: 最大迭代次数(用于 LPA 等迭代算法)
- `alpha`: PageRank 的阻尼因子(默认值:0.85)
- `sample_rate`: 采样率,用于 betweenness_centrality 等算法(0-1)
- `direction`: 边遍历方向(OUT、IN 或 BOTH)

##### 示例:提交 PageRank 任务

```json
{
"alpha": 0.85,
"max_iteration": 20
}
```

##### 响应状态

```json
201
```

##### 响应体

```json
{
"task_id": 1
}
```

响应仅包含任务 ID。使用 [任务 API](/docs/clients/restful-api/task) 监控任务。

#### 6.1.2 监控算法任务

使用 [任务 API](/docs/clients/restful-api/task) 检查算法任务的状态:

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CN docs this link points to the non-localized /docs/... path. Please use /cn/docs/clients/restful-api/task (or a relative link like ./task) so Chinese pages don’t redirect to the English site.

Suggested change
响应仅包含任务 ID。使用 [任务 API](/docs/clients/restful-api/task) 监控任务。
#### 6.1.2 监控算法任务
使用 [任务 API](/docs/clients/restful-api/task) 检查算法任务的状态:
响应仅包含任务 ID。使用 [任务 API](./task) 监控任务。
#### 6.1.2 监控算法任务
使用 [任务 API](./task) 检查算法任务的状态:

Copilot uses AI. Check for mistakes.

```
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/tasks/{task_id}
```

#### 6.1.3 检索算法结果

任务完成后(task_status = "success"),算法结果作为顶点属性存储。查询顶点以访问结果:

```
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/graph/vertices?filter=properties.{property_name}

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vertices query example uses filter=properties.{property_name}, but the Vertices API uses the properties={...} query parameter (see vertex.md “Get Vertices that Meet the Criteria”). This example should be updated to a valid format.

Suggested change
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/graph/vertices?filter=properties.{property_name}
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/graph/vertices?properties={"{property_name}":"{property_value}"}

Copilot uses AI. Check for mistakes.
```

按算法的常见结果属性名称:

| 算法 | 结果属性 |
|------|----------|
| pagerank | `page_rank` |
| lpa | `community` |
| wcc | `component` |
| degree_centrality | `degree` |
| closeness_centrality | `closeness` |
| betweenness_centrality | `betweenness` |
| triangle_count | `triangles` |

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result property table is malformed because rows start with || instead of |, which breaks Markdown rendering. Please switch to standard Markdown table syntax.

Copilot uses AI. Check for mistakes.

#### 6.1.4 支持的算法

- `pagerank`: 计算顶点重要性分数
- `lpa`: 用于社区检测的标签传播算法
- `wcc`: 弱连通分量
- `degree_centrality`: 顶点连通性度量
- `closeness_centrality`: 到其他顶点的平均距离
- `betweenness_centrality`: 基于最短路径的顶点重要性
- `triangle_count`: 计算图中的三角形

#### 6.1.5 性能考虑

对于非常大的图(数百万+个顶点/边),考虑使用 [HugeGraph-Computer](/docs/quickstart/computing/hugegraph-computer) 或 [HugeGraph-Vermeer](/docs/quickstart/computing/hugegraph-vermeer) 进行分布式计算,而不是 REST API。

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CN docs these links point to the non-localized /docs/... path. Please use /cn/docs/quickstart/computing/hugegraph-computer and /cn/docs/quickstart/computing/hugegraph-vermeer so navigation stays within the Chinese docs.

Suggested change
对于非常大的图(数百万+个顶点/边),考虑使用 [HugeGraph-Computer](/docs/quickstart/computing/hugegraph-computer)[HugeGraph-Vermeer](/docs/quickstart/computing/hugegraph-vermeer) 进行分布式计算,而不是 REST API。
对于非常大的图(数百万+个顶点/边),考虑使用 [HugeGraph-Computer](/cn/docs/quickstart/computing/hugegraph-computer)[HugeGraph-Vermeer](/cn/docs/quickstart/computing/hugegraph-vermeer) 进行分布式计算,而不是 REST API。

Copilot uses AI. Check for mistakes.
1 change: 1 addition & 0 deletions content/en/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [Rank](clients/restful-api/rank)
* [Variable](clients/restful-api/variable)
* [Graphs](clients/restful-api/graphs)
* [Algorithm](clients/restful-api/algorithm)
* [Task](clients/restful-api/task)
* [Gremlin](clients/restful-api/gremlin)
* [Cypher](clients/restful-api/cypher)
Expand Down
99 changes: 99 additions & 0 deletions content/en/docs/clients/restful-api/algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: "Algorithm API"
linkTitle: "Algorithm"
weight: 11
description: "Algorithm Job REST API: Submit and monitor asynchronous graph algorithm jobs."
---

### 6.1 Algorithm

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weight: 11 duplicates content/en/docs/clients/restful-api/variable.md (also weight 11), which can cause unstable ordering in Hugo menus. Also the section numbering starts at 6.1, but Graphs API already uses ### 6.1 (content/en/docs/clients/restful-api/graphs.md:8), so this page should use a non-conflicting number (e.g., 6.2 and 6.2.x).

Copilot uses AI. Check for mistakes.

The Algorithm API allows you to submit long-running graph algorithms as asynchronous jobs and track their progress.

#### 6.1.1 Submit an Algorithm Job

##### Method & Url

```
POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/jobs/algorithm/{algorithm_name}
```

For legacy setups without graphspaces:
Comment thread
morningstarxcdcode marked this conversation as resolved.
```
POST http://localhost:8080/graphs/{graph}/jobs/algorithm/{algorithm_name}
```
Comment thread
morningstarxcdcode marked this conversation as resolved.

##### Request Body

The request body varies by algorithm. Common parameters include:
Comment thread
morningstarxcdcode marked this conversation as resolved.

- `max_iteration`: Maximum number of iterations (used by iterative algorithms like LPA)
- `alpha`: Damping factor for PageRank (default: 0.85)
- `sample_rate`: Sampling rate for algorithms like betweenness_centrality (0-1)
- `direction`: Edge direction for traversal (OUT, IN, or BOTH)

##### Example: Submit a PageRank Job

```json
{
"alpha": 0.85,
"max_iteration": 20
}
```

##### Response Status

```json
201
```

##### Response Body

```json
{
"task_id": 1
}
```

The response contains only the task ID. Use the [Task API](/docs/clients/restful-api/task) to monitor the job.

#### 6.1.2 Monitor Algorithm Job

Use the [Task API](/docs/clients/restful-api/task) to check the status of an algorithm job:

```
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/tasks/{task_id}
```

#### 6.1.3 Retrieve Algorithm Results

Once the job completes (task_status = "success"), algorithm results are stored as vertex properties. Query vertices to access the results:

```
GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/graph/vertices?filter=properties.{property_name}
```

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vertices query example uses filter=properties.{property_name}, but the documented Vertices API supports properties={...} (see vertex.md “Get Vertices that Meet the Criteria”). This example should be updated to a valid query parameter format (or explicitly recommend Gremlin if presence-only filtering isn’t supported).

Copilot uses AI. Check for mistakes.

Common result property names by algorithm:

| Algorithm | Result Property |
|-----------|-----------------|
| pagerank | `page_rank` |
| lpa | `community` |
| wcc | `component` |
| degree_centrality | `degree` |
| closeness_centrality | `closeness` |
| betweenness_centrality | `betweenness` |
| triangle_count | `triangles` |

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result property table is malformed because each row starts with || instead of |, which breaks Markdown table rendering. Please change it to standard table syntax with single leading/trailing pipes.

Copilot uses AI. Check for mistakes.

#### 6.1.4 Supported Algorithms

- `pagerank`: Compute vertex importance scores
- `lpa`: Label Propagation Algorithm for community detection
- `wcc`: Weakly Connected Components
- `degree_centrality`: Vertex connectivity measure
- `closeness_centrality`: Average distance to other vertices
- `betweenness_centrality`: Vertex importance based on shortest paths
- `triangle_count`: Count triangles in the graph

#### 6.1.5 Performance Considerations

For very large graphs (millions+ vertices/edges), consider using [HugeGraph-Computer](/docs/quickstart/computing/hugegraph-computer) or [HugeGraph-Vermeer](/docs/quickstart/computing/hugegraph-vermeer) for distributed computation instead of the REST API.
Comment thread
morningstarxcdcode marked this conversation as resolved.
Loading