This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-doc.git
The following commit(s) were added to refs/heads/master by this push:
new 66cf8ef1 doc: update content about kout & kneighbor new feature (#283)
66cf8ef1 is described below
commit 66cf8ef15b54b9e1904ca3ce0f02b649ac58c9e9
Author: Wu Chencan <[email protected]>
AuthorDate: Fri Sep 15 11:15:58 2023 +0800
doc: update content about kout & kneighbor new feature (#283)
- kout & kneighbor: filtering for edge & vertex
- kout: traverse mode bfs & dfs
- kout & kneighbor: with_edge params
---------
Co-authored-by: imbajin <[email protected]>
---
content/cn/docs/clients/restful-api/traverser.md | 299 +++++++++++++++--------
content/en/docs/clients/restful-api/traverser.md | 292 +++++++++++++++-------
2 files changed, 402 insertions(+), 189 deletions(-)
diff --git a/content/cn/docs/clients/restful-api/traverser.md
b/content/cn/docs/clients/restful-api/traverser.md
index a1613c05..12d7cd3b 100644
--- a/content/cn/docs/clients/restful-api/traverser.md
+++ b/content/cn/docs/clients/restful-api/traverser.md
@@ -14,13 +14,13 @@ HugeGraph支持的Traverser API包括:
- 基础版使用GET方法,根据起始顶点,查找恰好N步可达的邻居
- 高级版使用POST方法,根据起始顶点,查找恰好N步可达的邻居,与基础版的不同在于:
- 支持只统计邻居数量
- - 支持边属性过滤
+ - 支持顶点和边属性过滤
- 支持返回到达邻居的最短路径
- K-neighbor API,根据起始顶点,查找N步以内可达的所有邻居,分为基础版和高级版:
- 基础版使用GET方法,根据起始顶点,查找N步以内可达的所有邻居
- 高级版使用POST方法,根据起始顶点,查找N步以内可达的所有邻居,与基础版的不同在于:
- 支持只统计邻居数量
- - 支持边属性过滤
+ - 支持顶点和边属性过滤
- 支持返回到达邻居的最短路径
- Same Neighbors, 查询两个顶点的共同邻居
- Jaccard Similarity API,计算jaccard相似度,包括两种:
@@ -253,23 +253,33 @@ GET
http://localhost:8080/graphs/{graph}/traversers/kout?source="1:marko"&max_de
###### Params
- source:起始顶点id,必填项
-- 从起始点出发的Step,必填项,结构如下:
+- steps: 从起始点出发的Steps,必填项,结构如下:
- direction:表示边的方向(OUT,IN,BOTH),默认是BOTH
- - labels:边的类型列表
- - properties:通过属性的值过滤边
+ - edge_steps:边Step集合,支持对单边的类型和属性过滤,如果为空,则不过滤
+ - label:边类型
+ - properties:边属性
+ - vertex_steps:顶点Step集合,支持对单点的类型和属性过滤,如果为空,则不过滤
+ - label:顶点类型
+ - properties:顶点属性
- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree
作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法)
- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree
时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意:
开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree
条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启)
- max_depth:步数,必填项
-
nearest:nearest为true时,代表起始顶点到达结果顶点的最短路径长度为depth,不存在更短的路径;nearest为false时,代表起始顶点到结果顶点有一条长度为depth的路径(未必最短且可以有环),选填项,默认为true
- count_only:Boolean值,true表示只统计结果的数目,不返回具体结果;false表示返回具体的结果,默认为false
- with_path:true表示返回起始点到每个邻居的最短路径,false表示不返回起始点到每个邻居的最短路径,选填项,默认为false
+- with_edge,选填项,默认为false:
+ - 如果设置为true,则结果将包含所有边的完整信息,即路径中的所有边
+ - 当with_path为true时,将返回所有路径中的边的完整信息
+ - 当with_path为false时,不返回任何信息
+ - 如果设置为false,则仅返回边的id
- with_vertex,选填项,默认为false:
- - true表示返回结果包含完整的顶点信息(路径中的全部顶点)
- - with_path为true时,返回所有路径中的顶点的完整信息
- - with_path为false时,返回所有邻居的完整信息
- - false时表示只返回顶点id
+ - 如果设置为true,则结果将包含所有顶点的完整信息,即路径中的所有顶点
+ - 当with_path为true时,将返回所有路径中的顶点的完整信息
+ - 当with_path为false时,返回所有邻居顶点的完整信息
+ - 如果设置为false,则仅返回顶点的id
- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000
- limit:返回的顶点的最大数目,选填项,默认为10000000
+- traverse_mode:
遍历方式,可选择“breadth_first_search”或“depth_first_search”作为参数,默认为“breadth_first_search”
##### 3.2.2.2 使用方法
@@ -283,21 +293,44 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
```json
{
- "source": "1:marko",
- "step": {
- "direction": "BOTH",
- "labels": ["knows", "created"],
- "properties": {
- "weight": "P.gt(0.1)"
+ "source": "1:marko",
+ "steps": {
+ "direction": "BOTH",
+ "edge_steps": [
+ {
+ "label": "knows",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ },
+ {
+ "label": "created",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ }
+ ],
+ "vertex_steps": [
+ {
+ "label": "person",
+ "properties": {
+ "age": "P.lt(32)"
+ }
+ },
+ {
+ "label": "software",
+ "properties": {}
+ }
+ ],
+ "max_degree": 10000,
+ "skip_degree": 100000
},
- "max_degree": 10000,
- "skip_degree": 100000
- },
- "max_depth": 1,
- "nearest": true,
- "limit": 10000,
- "with_vertex": true,
- "with_path": true
+ "max_depth": 1,
+ "nearest": true,
+ "limit": 10000,
+ "with_vertex": true,
+ "with_path": true,
+ "with_edge": true
}
```
@@ -311,9 +344,8 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
```json
{
- "size": 3,
- "kout": [
- "1:josh",
+ "size": 2,
+ "kout": [
"1:vadas",
"2:lop"
],
@@ -321,7 +353,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
{
"objects": [
"1:marko",
- "1:josh"
+ "2:lop"
]
},
{
@@ -329,12 +361,6 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"1:marko",
"1:vadas"
]
- },
- {
- "objects": [
- "1:marko",
- "2:lop"
- ]
}
],
"vertices": [
@@ -348,16 +374,6 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"city": "Beijing"
}
},
- {
- "id": "1:josh",
- "label": "person",
- "type": "vertex",
- "properties": {
- "name": "josh",
- "age": 32,
- "city": "Beijing"
- }
- },
{
"id": "1:vadas",
"label": "person",
@@ -378,6 +394,34 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"price": 328
}
}
+ ],
+ "edges": [
+ {
+ "id": "S1:marko>1>20160110>S1:vadas",
+ "label": "knows",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "1:vadas",
+ "inVLabel": "person",
+ "properties": {
+ "weight": 0.5,
+ "date": "20160110"
+ }
+ },
+ {
+ "id": "S1:marko>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.4,
+ "date": "20171210"
+ }
+ }
]
}
@@ -455,20 +499,31 @@ GET
http://localhost:8080/graphs/{graph}/traversers/kneighbor?source=“1:marko
###### Params
- source:起始顶点id,必填项
-- 从起始点出发的Step,必填项,结构如下:
+- steps: 从起始点出发的Steps,必填项,结构如下:
- direction:表示边的方向(OUT,IN,BOTH),默认是BOTH
- - labels:边的类型列表
- - properties:通过属性的值过滤边
+ - 从起始点出发的Steps,必填项,结构如下:
+ - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH
+ - edge_steps:边Step集合,支持对单边的类型和属性过滤,如果为空,则不过滤
+ - label:边类型
+ - properties:边属性
+ - vertex_steps:顶点Step集合,支持对单点的类型和属性过滤,如果为空,则不过滤
+ - label:顶点类型
+ - properties:顶点属性
- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree
作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法)
- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree
时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意:
开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree
条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启)
- max_depth:步数,必填项
- count_only:Boolean值,true表示只统计结果的数目,不返回具体结果;false表示返回具体的结果,默认为false
- with_path:true表示返回起始点到每个邻居的最短路径,false表示不返回起始点到每个邻居的最短路径,选填项,默认为false
+- with_edge,选填项,默认为false:
+ - 如果设置为true,则结果将包含所有边的完整信息,即路径中的所有边
+ - 当with_path为true时,将返回所有路径中的边的完整信息
+ - 当with_path为false时,不返回任何信息
+ - 如果设置为false,则仅返回边的id
- with_vertex,选填项,默认为false:
- - true表示返回结果包含完整的顶点信息(路径中的全部顶点)
- - with_path为true时,返回所有路径中的顶点的完整信息
- - with_path为false时,返回所有邻居的完整信息
- - false时表示只返回顶点id
+ - 如果设置为true,则结果将包含所有顶点的完整信息,即路径中的所有顶点
+ - 当with_path为true时,将返回所有路径中的顶点的完整信息
+ - 当with_path为false时,返回所有邻居顶点的完整信息
+ - 如果设置为false,则仅返回顶点的id
- limit:返回的顶点的最大数目,选填项,默认为10000000
##### 3.2.4.2 使用方法
@@ -483,20 +538,39 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
```json
{
- "source": "1:marko",
- "step": {
- "direction": "BOTH",
- "labels": ["knows", "created"],
- "properties": {
- "weight": "P.gt(0.1)"
- },
- "max_degree": 10000,
- "skip_degree": 100000
- },
- "max_depth": 3,
- "limit": 10000,
- "with_vertex": true,
- "with_path": true
+ "source": "1:marko",
+ "steps": {
+ "direction": "BOTH",
+ "edge_steps": [
+ {
+ "label": "knows",
+ "properties": {}
+ },
+ {
+ "label": "created",
+ "properties": {}
+ }
+ ],
+ "vertex_steps": [
+ {
+ "label": "person",
+ "properties": {
+ "age": "P.gt(28)"
+ }
+ },
+ {
+ "label": "software",
+ "properties": {}
+ }
+ ],
+ "max_degree": 10000,
+ "skip_degree": 100000
+ },
+ "max_depth": 3,
+ "limit": 10000,
+ "with_vertex": true,
+ "with_path": true,
+ "with_edge": true
}
```
@@ -510,51 +584,38 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
```json
{
- "size": 6,
- "kneighbor": [
- "2:ripple",
- "1:marko",
+ "size": 4,
+ "kneighbor": [
"1:josh",
- "1:vadas",
+ "2:lop",
"1:peter",
- "2:lop"
+ "2:ripple"
],
"paths": [
{
"objects": [
"1:marko",
- "1:josh",
- "2:ripple"
- ]
- },
- {
- "objects": [
- "1:marko"
- ]
- },
- {
- "objects": [
- "1:marko",
- "1:josh"
+ "2:lop"
]
},
{
"objects": [
"1:marko",
- "1:vadas"
+ "2:lop",
+ "1:peter"
]
},
{
"objects": [
"1:marko",
- "2:lop",
- "1:peter"
+ "1:josh"
]
},
{
"objects": [
"1:marko",
- "2:lop"
+ "1:josh",
+ "2:ripple"
]
}
],
@@ -589,16 +650,6 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
"city": "Beijing"
}
},
- {
- "id": "1:vadas",
- "label": "person",
- "type": "vertex",
- "properties": {
- "name": "vadas",
- "age": 27,
- "city": "Hongkong"
- }
- },
{
"id": "1:peter",
"label": "person",
@@ -619,6 +670,60 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
"price": 328
}
}
+ ],
+ "edges": [
+ {
+ "id": "S1:josh>2>>S2:ripple",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:josh",
+ "outVLabel": "person",
+ "inV": "2:ripple",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 1.0,
+ "date": "20171210"
+ }
+ },
+ {
+ "id": "S1:marko>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.4,
+ "date": "20171210"
+ }
+ },
+ {
+ "id": "S1:marko>1>20130220>S1:josh",
+ "label": "knows",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "1:josh",
+ "inVLabel": "person",
+ "properties": {
+ "weight": 1.0,
+ "date": "20130220"
+ }
+ },
+ {
+ "id": "S1:peter>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:peter",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.2,
+ "date": "20170324"
+ }
+ }
]
}
```
diff --git a/content/en/docs/clients/restful-api/traverser.md
b/content/en/docs/clients/restful-api/traverser.md
index fda95da7..f6b21ee9 100644
--- a/content/en/docs/clients/restful-api/traverser.md
+++ b/content/en/docs/clients/restful-api/traverser.md
@@ -14,13 +14,13 @@ The Traverser API supported by HugeGraph includes:
- The basic version uses the GET method to find neighbors that are exactly
N steps away from a given starting vertex.
- The advanced version uses the POST method to find neighbors that are
exactly N steps away from a given starting vertex. The advanced version differs
from the basic version in the following ways:
- Supports counting the number of neighbors only
- - Supports filtering by edge properties
+ - Supports filtering by edge and vertex properties
- Supports returning the shortest path to reach the neighbor
- K-neighbor API: It finds all neighbors that are within N steps of a given
starting vertex. There are two versions:
- The basic version uses the GET method to find all neighbors that are
within N steps of a given starting vertex.
- The advanced version uses the POST method to find all neighbors that are
within N steps of a given starting vertex. The advanced version differs from
the basic version in the following ways:
- Supports counting the number of neighbors only
- - Supports filtering by edge properties
+ - Supports filtering by edge and vertex properties
- Supports returning the shortest path to reach the neighbor
- Same Neighbors: It queries the common neighbors of two vertices.
- Jaccard Similarity API: It calculates the Jaccard similarity, which includes
two types:
@@ -257,23 +257,33 @@ The K-out API allows you to find vertices that are
exactly "depth" steps away fr
###### Params
- source: The ID of the starting vertex, required.
-- Step from the starting point, required, with the following structure:
+- steps: Steps from the starting point, required, with the following structure:
- direction: Represents the direction of the edges (OUT, IN, BOTH),
default is BOTH.
- - labels: List of edge types.
- - properties: Filters edges based on property values.
+ - edge_steps: The step set of edges, supporting label and properties
filtering for the edge. If edge_steps is empty, the edge is not filtered.
+ - label: Edge types.
+ - properties: Filter edges based on property values.
+ - vertex_steps: The step set of vertices, supporting label and properties
filtering for the vertex. If vertex_steps is empty, the vertex is not filtered.
+ - label: Vertex types.
+ - properties: Filter vertices based on property values.
- max_degree: Maximum number of adjacent edges to traverse for a single
vertex, default is 10000 (Note: Prior to version 0.12, the parameter name was
"degree" instead of "max_degree". Starting from version 0.12, "max_degree" is
used uniformly, while still supporting the "degree" syntax for backward
compatibility).
- skip_degree: Sets the minimum number of edges to skip super vertices
during the query process. If the number of adjacent edges for a vertex is
greater than skip_degree, the vertex is completely skipped. Optional. If
enabled, it should satisfy the constraint `skip_degree >= max_degree`. Default
is 0 (not enabled), indicating no skipping of any vertices (Note: Enabling this
configuration means that during traversal, an attempt will be made to access
skip_degree edges of a vertex, not [...]
- max_depth: Number of steps, required.
- nearest: When nearest is true, it means the shortest path length from the
starting vertex to the result vertex is equal to depth, and there is no shorter
path. When nearest is false, it means there is a path of length depth from the
starting vertex to the result vertex (not necessarily the shortest and can
contain cycles). Optional, default is true.
- count_only: Boolean value, true indicates only counting the number of
results without returning specific results, false indicates returning specific
results. Default is false.
- with_path: When true, it returns the shortest path from the starting vertex
to each neighbor. When false, it does not return the shortest path. Optional,
default is false.
-- with_vertex: Optional, default is false:
- - When true, the results include complete vertex information (all vertices
in the path):
+- with_edge: Optional parameter, default is false:
+ - When true, the result will include complete edge information (all edges
in the path):
+ - When with_path is true, it returns complete information of all edges
in all paths.
+ - When with_path is false, no information is returned.
+ - When false, it only returns edge IDs.
+- with_vertex: Optional parameter, default is false:
+ - When true, the result will include complete vertex information (all
vertices in the path):
- When with_path is true, it returns complete information of all
vertices in all paths.
- When with_path is false, it returns complete information of all
neighbors.
- When false, it only returns vertex IDs.
- capacity: Maximum number of vertices to visit during traversal. Optional,
default is 10000000.
- limit: Maximum number of vertices to return. Optional, default is 10000000.
+- traverse_mode: Traversal mode. There are two options: "breadth_first_search"
and "depth_first_search", default is "breadth_first_search".
##### 3.2.2.2 Usage
@@ -287,21 +297,44 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
```json
{
- "source": "1:marko",
- "step": {
- "direction": "BOTH",
- "labels": ["knows", "created"],
- "properties": {
- "weight": "P.gt(0.1)"
+ "source": "1:marko",
+ "steps": {
+ "direction": "BOTH",
+ "edge_steps": [
+ {
+ "label": "knows",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ },
+ {
+ "label": "created",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ }
+ ],
+ "vertex_steps": [
+ {
+ "label": "person",
+ "properties": {
+ "age": "P.lt(32)"
+ }
+ },
+ {
+ "label": "software",
+ "properties": {}
+ }
+ ],
+ "max_degree": 10000,
+ "skip_degree": 100000
},
- "max_degree": 10000,
- "skip_degree": 100000
- },
- "max_depth": 1,
- "nearest": true,
- "limit": 10000,
- "with_vertex": true,
- "with_path": true
+ "max_depth": 1,
+ "nearest": true,
+ "limit": 10000,
+ "with_vertex": true,
+ "with_path": true,
+ "with_edge": true
}
```
@@ -315,9 +348,8 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
```json
{
- "size": 3,
+ "size": 2,
"kout": [
- "1:josh",
"1:vadas",
"2:lop"
],
@@ -325,7 +357,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
{
"objects": [
"1:marko",
- "1:josh"
+ "2:lop"
]
},
{
@@ -333,12 +365,6 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"1:marko",
"1:vadas"
]
- },
- {
- "objects": [
- "1:marko",
- "2:lop"
- ]
}
],
"vertices": [
@@ -352,16 +378,6 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"city": "Beijing"
}
},
- {
- "id": "1:josh",
- "label": "person",
- "type": "vertex",
- "properties": {
- "name": "josh",
- "age": 32,
- "city": "Beijing"
- }
- },
{
"id": "1:vadas",
"label": "person",
@@ -382,6 +398,34 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout
"price": 328
}
}
+ ],
+ "edges": [
+ {
+ "id": "S1:marko>1>20160110>S1:vadas",
+ "label": "knows",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "1:vadas",
+ "inVLabel": "person",
+ "properties": {
+ "weight": 0.5,
+ "date": "20160110"
+ }
+ },
+ {
+ "id": "S1:marko>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.4,
+ "date": "20171210"
+ }
+ }
]
}
@@ -458,20 +502,29 @@ Find all vertices that are reachable within depth steps
from the starting vertex
###### Params
- source: Starting vertex ID, required.
-- Step from the starting point, required, with the following structure:
- - direction: Represents the direction of edges (OUT, IN, BOTH). Default is
BOTH.
- - labels: List of edge types.
- - properties: Filter edges based on property values.
+- steps: Steps from the starting point, required, with the following structure:
+ - direction: Represents the direction of the edges (OUT, IN, BOTH),
default is BOTH.
+ - edge_steps: The step set of edges, supporting label and properties
filtering for the edge. If edge_steps is empty, the edge is not filtered.
+ - label: Edge types.
+ - properties: Filter edges based on property values.
+ - vertex_steps: The step set of vertices, supporting label and properties
filtering for the vertex. If vertex_steps is empty, the vertex is not filtered.
+ - label: Vertex types.
+ - properties: Filter vertices based on property values.
- max_degree: Maximum number of adjacent edges to traverse for each vertex
during the query process. Default is 10000. (Note: Before version 0.12, the
parameter name within the step only supported "degree." Starting from version
0.12, it is unified as "max_degree" and is backward compatible with the
"degree" notation.)
- skip_degree: Used to set the minimum number of edges to discard super
vertices during the query process. When the number of adjacent edges for a
vertex exceeds skip_degree, the vertex is completely discarded. This is an
optional parameter. If enabled, it should satisfy the constraint `skip_degree
>= max_degree`. Default is 0 (not enabled), which means no vertices are
skipped. (Note: When this configuration is enabled, the traversal will attempt
to access skip_degree edges for each [...]
- max_depth: Number of steps, required.
- count_only: Boolean value. If true, only the count of results is returned
without the actual results. If false, the specific results are returned.
Default is false.
- with_path: If true, the shortest path from the starting point to each
neighbor is returned. If false, the shortest path from the starting point to
each neighbor is not returned. This is an optional parameter. Default is false.
+- with_edge: Optional parameter, default is false:
+ - When true, the result will include complete edge information (all edges
in the path):
+ - When with_path is true, it returns complete information of all edges
in all paths.
+ - When with_path is false, no information is returned.
+ - When false, it only returns edge IDs.
- with_vertex: Optional parameter, default is false:
- - If true, the results include complete vertex information (all vertices
in the path).
- - When with_path is true, it returns complete information of all
vertices in the paths.
+ - When true, the result will include complete vertex information (all
vertices in the path):
+ - When with_path is true, it returns complete information of all
vertices in all paths.
- When with_path is false, it returns complete information of all
neighbors.
- - If false, only the vertex ID is returned.
+ - When false, it only returns vertex IDs.
- limit: Maximum number of vertices to be returned. Also, the maximum number
of vertices visited during the traversal process. This is an optional
parameter. Default is 10000000.
##### 3.2.4.2 Usage Method
@@ -486,20 +539,44 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
```json
{
- "source": "1:marko",
- "step": {
- "direction": "BOTH",
- "labels": ["knows", "created"],
- "properties": {
- "weight": "P.gt(0.1)"
+ "source": "1:marko",
+ "steps": {
+ "direction": "BOTH",
+ "edge_steps": [
+ {
+ "label": "knows",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ },
+ {
+ "label": "created",
+ "properties": {
+ "weight": "P.gt(0.1)"
+ }
+ }
+ ],
+ "vertex_steps": [
+ {
+ "label": "person",
+ "properties": {
+ "age": "P.lt(32)"
+ }
+ },
+ {
+ "label": "software",
+ "properties": {}
+ }
+ ],
+ "max_degree": 10000,
+ "skip_degree": 100000
},
- "max_degree": 10000,
- "skip_degree": 100000
- },
- "max_depth": 3,
- "limit": 10000,
- "with_vertex": true,
- "with_path": true
+ "max_depth": 1,
+ "nearest": true,
+ "limit": 10000,
+ "with_vertex": true,
+ "with_path": true,
+ "with_edge": true
}
```
@@ -513,51 +590,38 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
```json
{
- "size": 6,
+ "size": 4,
"kneighbor": [
- "2:ripple",
- "1:marko",
"1:josh",
- "1:vadas",
+ "2:lop",
"1:peter",
- "2:lop"
+ "2:ripple"
],
"paths": [
{
"objects": [
"1:marko",
- "1:josh",
- "2:ripple"
- ]
- },
- {
- "objects": [
- "1:marko"
- ]
- },
- {
- "objects": [
- "1:marko",
- "1:josh"
+ "2:lop"
]
},
{
"objects": [
"1:marko",
- "1:vadas"
+ "2:lop",
+ "1:peter"
]
},
{
"objects": [
"1:marko",
- "2:lop",
- "1:peter"
+ "1:josh"
]
},
{
"objects": [
"1:marko",
- "2:lop"
+ "1:josh",
+ "2:ripple"
]
}
],
@@ -592,16 +656,6 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
"city": "Beijing"
}
},
- {
- "id": "1:vadas",
- "label": "person",
- "type": "vertex",
- "properties": {
- "name": "vadas",
- "age": 27,
- "city": "Hongkong"
- }
- },
{
"id": "1:peter",
"label": "person",
@@ -622,6 +676,60 @@ POST
http://localhost:8080/graphs/{graph}/traversers/kneighbor
"price": 328
}
}
+ ],
+ "edges": [
+ {
+ "id": "S1:josh>2>>S2:ripple",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:josh",
+ "outVLabel": "person",
+ "inV": "2:ripple",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 1.0,
+ "date": "20171210"
+ }
+ },
+ {
+ "id": "S1:marko>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.4,
+ "date": "20171210"
+ }
+ },
+ {
+ "id": "S1:marko>1>20130220>S1:josh",
+ "label": "knows",
+ "type": "edge",
+ "outV": "1:marko",
+ "outVLabel": "person",
+ "inV": "1:josh",
+ "inVLabel": "person",
+ "properties": {
+ "weight": 1.0,
+ "date": "20130220"
+ }
+ },
+ {
+ "id": "S1:peter>2>>S2:lop",
+ "label": "created",
+ "type": "edge",
+ "outV": "1:peter",
+ "outVLabel": "person",
+ "inV": "2:lop",
+ "inVLabel": "software",
+ "properties": {
+ "weight": 0.2,
+ "date": "20170324"
+ }
+ }
]
}
```