Updated on 2022-12-08 GMT+08:00

Filtered n-Paths (2.2.22)

Introduction

The filtered n-Paths algorithm is used to find no more than n k-hop loop-free paths between the source and target vertices. The start vertex (source), end vertex (target), number of hops (k), number of paths (n), and filter criteria (filters) are the parameters for the algorithm.

  • Algorithm name: filtered_n_paths
  • filtered_n_paths

Applicable Scope

Any network

Request Parameters

Table 1 Body format

Field

Mandatory

Type

Description

algorithmName

Yes

String

The value is filtered_n_paths.

parameters

Yes

JSON format

For details about the format, see Table 2.

filters

Yes

JSon Array

Filter criteria. Each element in the array corresponds to a filter. For details about the format, see Table 3.

Table 2 Parameter description

Parameter

Mandatory

Description

Type

Value Range

Default Value

source

Yes

Source vertex

String

Internal vertices

None

target

Yes

Target vertex

String

Internal vertices

None

k

Yes

Number of hops

Int

[2,6]

2

n

Yes

Number of paths

Int

[1,1000]

1

Table 3 filters element format

Parameter

Mandatory

Type

Value Range

Default Value

Description

edge_filter

No

json

N/A

N/A

Filter criteria for full-graph edge query

vertex_filter

No

json

None

None

Filter criteria for full-graph vertex query

Table 4 response_data parameter description

Field

Mandatory

Type

Description

path_length

Yes

int

Path length

paths_number

Yes

int

Number of paths

paths

Yes

JsonArray

Path set. Example value: ["111","119","58","96","82","57","56"].

source

Yes

String

Source vertex

target

Yes

String

Target vertex

Example Request

POST http://IP:PORT/ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=execute-algorithm
{
    "algorithmName": "filtered_n_paths",
    "filters": [
    {
        "edge_filter":
        {
            "property_filter":
            {
                "leftvalue":
                {
                    "label_name": "labelName"
                },
                "predicate": "=",
                "rightvalue":
                {
                    "value": "default"
                }
            }
        }
    }],
    "parameters":
    {
        "k": 6,
        "n": 100,
        "source": "111",
        "target": "56"
    }
}

Response

{
    "jobId": "b14f6380-f115-46ab-990e-9a76a984ebd2154236181",
    "jobType": 2
}

Example for Querying a Job

GET http://IP:PORT/ges/v1.0/{project_id}/graphs/{graph_name}/jobs/{jobId}/status

Query Result

{
    "data": {
        "outputs": {
            "data_return_size": 3,
            "paths": [
                [
                    "111",
                    "119",
                    "58",
                    "96",
                    "82",
                    "57",
                    "56"
                ],
                [
                    "111",
                    "119",
                    "58",
                    "61",
                    "76",
                    "57",
                    "56"
                ],
                [
                    "111",
                    "119",
                    "58",
                    "79",
                    "76",
                    "57",
                    "56"
                ]
            ],
            "runtime": 0.000308,
            "source": "111",
            "path_length": 6,
            "data_offset": 0,
            "paths_number": 3,
            "data_total_size": 3,
            "target": "56"
        }
    },
    "status": "success"
}