Skip to content

Commit

Permalink
Modify the description of graph pattern (#119) (#2385)
Browse files Browse the repository at this point in the history
* Modify the description of graph pattern

The upper and lower bounds of the graph pattern can be set.

* Update 2.match.md

* update

* update

* Update 3.graph-patterns.md
  • Loading branch information
cooper-lzy authored Dec 5, 2023
1 parent 35d7f2a commit 9e1e059
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
15 changes: 4 additions & 11 deletions docs-2.0-en/3.ngql-guide/1.nGQL-overview/3.graph-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,14 @@ The preceding example defines a path with a minimum length of 3 and a maximum le

It describes a graph of either 4 vertices and 3 edges, 5 vertices and 4 edges, or 6 vertices and 5 edges, all connected in a single path.

The lower bound can be omitted. For example, to describe paths of length 5 or less, use:
You may specify either the upper limit or lower limit of the length range, or neither of them, for example:

```ngql
(a)-[*..5]->(b)
(a)-[*..5]->(b) // The minimum length is 1 and the maximum length is 5.
(a)-[*3..]->(b) // The minimum length is 3 and the maximum length is infinity.
(a)-[*]->(b) // The minimum length is 1 and the maximum length is infinity.
```

!!! note

The upper bound must be specified. The following are **NOT** accepted.

```ngql
(a)-[*3..]->(b)
(a)-[*]->(b)
```

## Assigning to path variables

As described above, a series of connected vertices and edges is called a `path`. nGQL allows
Expand Down
14 changes: 8 additions & 6 deletions docs-2.0-en/3.ngql-guide/7.general-query-statements/2.match.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,18 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) -[*0]-> (v2) \

### Match variable-length paths

You can use the `:<edge_type>*[minHop..maxHop]` pattern to match variable-length paths.`minHop` and `maxHop` are optional and default to 1
and infinity respectively.
You can use the `:<edge_type>*[minHop..maxHop]` pattern to match variable-length paths.`minHop` and `maxHop` are optional and default to 1 and infinity respectively.

!!! note
!!! caution

When setting bounds, at least one of `minHop` and `maxHop` exists.
If `maxHop` is not set, it may cause the Graph service to OOM. Execute this command with caution.

!!! caution
| Parameter | Description |
| :------- | :----------------------------------------------------------------------- |
| `minHop` | Optional. `minHop` indicates the minimum length of the path, which must be a non-negative integer. The default value is 1. |
| `maxHop` | Optional. `maxHop` indicates the maximum length of the path, which must be a non-negative integer. The default value is infinity. |

If `maxHop` is not set, it may cause the Graph service to OOM, execute this command with caution.
If neither `minHop` nor `maxHop` is specified, and only `:<edge_type>*` is set, the default values are applied to both, i.e., `minHop` is 1 and `maxHop` is infinity.

```ngql
nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*]->(v2) \
Expand Down
10 changes: 4 additions & 6 deletions docs-2.0-zh/3.ngql-guide/1.nGQL-overview/3.graph-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@

该模式描述了 4 点 3 边、5 点 4 边或 6 点 5 边组成的图。

也可以忽略最小长度,只指定最大长度,例如:
也可以指定长度范围的上限或下限,也可以两个都不指定,例如:

```ngql
(a)-[*..5]->(b)
(a)-[*..5]->(b) // 最小长度为 1,最大长度为 5。
(a)-[*3..]->(b) // 最小长度为 3,最大长度为无穷大。
(a)-[*]->(b) // 最小长度为 1,最大长度为无穷大。
```

!!! note

必须指定最大长度,**不支持**仅指定最小长度(`(a)-[*3..]->(b)`)或都不指定(`(a)-[*]->(b)`)。

## 路径变量

一系列连接的点和边称为`路径`。nGQL 允许使用变量来命名路径,例如:
Expand Down

0 comments on commit 9e1e059

Please sign in to comment.