Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support-allShortestPaths #2527

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
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
39 changes: 27 additions & 12 deletions docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) -[*0]-> (v2) \

如果未设置 `maxHop` 可能会导致 graph 服务 OOM,请谨慎执行该命令。

|参数|说明|
|:---|:---|
|`minHop`|可选项。表示路径的最小长度。`minHop`必须是一个非负整数,默认值为 1。|
|`maxHop`|可选项。表示路径的最大长度。`maxHop`必须是一个非负整数,默认值为无穷大。|
| 参数 | 说明 |
| :------- | :----------------------------------------------------------------------- |
| `minHop` | 可选项。表示路径的最小长度。`minHop`必须是一个非负整数,默认值为 1。 |
| `maxHop` | 可选项。表示路径的最大长度。`maxHop`必须是一个非负整数,默认值为无穷大。 |

如果未指定`minHop`和`maxHop`,仅设置了`:<edge_type>*`,则二者都应用默认值,即`minHop`为 1,`maxHop`为无穷大。

Expand Down Expand Up @@ -613,18 +613,33 @@ nebula> MATCH (v1:player{name:"Tim Duncan"}), (v2:team{name:"Spurs"}) \

### 匹配最短路径

用户可以用 `shortestPath` 表示模式中的路径
用户可以使用`allShortestPaths`返回起始点到目标点的所有最短路径

```
nebula> MATCH p = shortestPath((a:player)-[e:follow*..2]-(b:player))\
WHERE a.player.age > 45 AND b.player.age < 30 \
nebula> MATCH p = allShortestPaths((a:player{name:"Tim Duncan"})-[e*..5]-(b:player{name:"Tony Parker"})) \
RETURN p;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| p |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| <("player144" :player{age: 47, name: "Shaquille O'Neal"})-[:follow@0 {degree: 80}]->("player100" :player{age: 42, name: "Tim Duncan"})<-[:follow@0 {degree: 99}]-("player113" :player{age: 29, name: "Dejounte Murray"})> |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------------------------------------------+
| p |
+------------------------------------------------------------------------------------------------------------------------------------+
| <("player100" :player{age: 42, name: "Tim Duncan"})<-[:follow@0 {degree: 95}]-("player101" :player{age: 36, name: "Tony Parker"})> |
| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})> |
+------------------------------------------------------------------------------------------------------------------------------------+
```


用户可以使用`shortestPath`返回起始点到目标点的任意一条最短路径。

```
nebula> MATCH p = shortestPath((a:player{name:"Tim Duncan"})-[e*..5]-(b:player{name:"Tony Parker"})) \
RETURN p;
+------------------------------------------------------------------------------------------------------------------------------------+
| p |
+------------------------------------------------------------------------------------------------------------------------------------+
| <("player100" :player{age: 42, name: "Tim Duncan"})<-[:follow@0 {degree: 95}]-("player101" :player{age: 36, name: "Tony Parker"})> |
+------------------------------------------------------------------------------------------------------------------------------------+

```

## 多MATCH检索

不同的模式有不同的筛选条件时,可以使用多`MATCH`,会返回模式完全匹配的行。
Expand Down