Updated on 2025-03-05 GMT+08:00

Querying Tree Details

Function

After you input a vertex, a tree starting from the vertex is output, including nodes and edges in the tree, and information about reachable paths. Parameters can be the direction (out, in, and out and in), maximum number of hops, and edge properties to be filtered.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=query-tree
Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

graph_name

Yes

String

Graph name

Example Request

Post /ges/v1.0/{project_id}/graphs/test/action?action_id=query-tree
{
    "executionMode": "sync",
    "rootId": "0",
    "maxDepth": 20,
    "maxVertices": 5000,
    "maxEdges": 10000,
    "maxDegree": 1000,
    "direction": "both",
    "labelFilters": [
        "edge",
        "default"
    ],
    "withVertex": true,
    "withEdge": true
}

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

executionMode

No

String

  • sync: synchronous
  • async: asynchronous

The default value is async, indicating asynchronous response.

rootId

Yes

String

ID of the root node

maxDepth

Yes

Integer

Tree depth, that is, the maximum length of a path. The value ranges from 1 to 20.

direction

Yes

String

Possible values:

in: Query incoming edges.

out: Query outgoing edges.

both: Query edges in both directions.

labelFilters

No

Array of Json

Whether to filter paths by label. The default value is [].

maxVertices

Yes

Integer

Maximum number of vertices that can be obtained. The value ranges from 0 to 200,000 (excluding 0).

maxEdges

Yes

Integer

Maximum number of edges that can be obtained. The value ranges from 0 to 200,000 (excluding 0).

maxDegree

No

Long

This parameter is used to access a super node. When the number of unidirectionally connected edges of an accessed node is greater than maxDegree, the next hop of the node will not be accessed.

withVertex

No

Boolean

Whether to output the vertex data. The default value is true.

withEdge

No

Boolean

Whether to output the edge data. The default value is true.

In asynchronous mode, vertex and edge data is output at the same time. Pagination is not supported.

Response Parameters

Table 3 Response body parameters

Parameter

Type

Description

errorMessage

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error message.

errorCode

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error code.

data

Object

Query results. For details, see Table 4 and Table 5.

This parameter is left blank when the query fails.

Table 4 Synchronous data parameter description

Parameter

Type

Description

vertices

List

Vertex result set. If no corresponding vertices are found, the value of vertices is empty.

edges

List

Edge result set. If no corresponding edges are found, the value of edges is empty.

Table 5 Asynchronous data parameter description

Parameter

Type

Description

jobId

String

ID of the algorithm execution job. This parameter is left blank when the request fails.

jobType

Integer

Job type. This parameter is left blank when the request fails.

Example Response

  • Synchronous call

    Status code: 200

    Example response (successful request)

    Http Status Code: 200
    {
    "data": {
       "edges" : [
          {
             "index" : "0",
             "label" : "edge",
             "properties" : {
                "_type" : [ "ACTED_IN" ],
                "role" : [ "Neo" ]
             },
             "source" : "546",
             "target" : "0"
          },
         ...
       ],
       "vertices" : [
          {
             "id" : "546",
             "label" : "node",
             "properties" : {
                "_labels" : [ "Actor" ],
                "d" : [ "" ],
                "name" : [ "Keanu Reeves" ],
                "personId" : [ "keanu" ],
                "title" : [ "" ],
                "year" : [ "" ]
             }
          },
       ...
       ]
    }
    }
    

    Status code: 400

    Example response (failed request)
    Http Status Code: 400
    {
        "errorMessage": "graph [test] is not found",
        "errorCode": "GES.8808"
    }
  • Asynchronous call

    Status code: 200

    Example response (successful request)
    {
        "jobId": "aca63a57-55f9-4c6e-932f-bcd6b87f7ab4",
        "jobType": 1
    }

    Status code: 400

    Example response (failed request)

    Http Status Code: 400
    {
        "errorMessage": "executionMode is not correct, it should be sync or async",
        "errorCode": "GES.8808"
    }

Status Codes

Return Value

Description

400 Bad Request

Request error.

401 Unauthorized

Authorization failed.

403 Forbidden

No operation permissions.

404 Not Found

No resources found.

500 Internal Server Error

Internal server error.

503 Service Unavailable

Service unavailable.

Error Codes

See Error Codes.