Skip to content

Commit 31d7911

Browse files
authored
add-find-single-shortest-path (#2236)
1 parent 71eb73e commit 31d7911

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md

+37-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The `FIND PATH` statement finds the paths between the selected source vertices a
99
## Syntax
1010

1111
```ngql
12-
FIND { SHORTEST | ALL | NOLOOP } PATH [WITH PROP] FROM <vertex_id_list> TO <vertex_id_list>
12+
FIND { SHORTEST | SINGLE SHORTEST | ALL | NOLOOP } PATH [WITH PROP] FROM <vertex_id_list> TO <vertex_id_list>
1313
OVER <edge_type_list> [REVERSELY | BIDIRECT]
1414
[<WHERE clause>] [UPTO <N> {STEP|STEPS}]
1515
YIELD path as <alias>
@@ -19,7 +19,9 @@ YIELD path as <alias>
1919
[vertex_id [, vertex_id] ...]
2020
```
2121

22-
- `SHORTEST` finds the shortest path.
22+
- `SHORTEST` finds all the shortest path.
23+
24+
- `SINGLE SHORTEST` finds the all shortest path. If there are multiple shortest paths, only one path is returned.
2325

2426
- `ALL` finds all the paths.
2527

@@ -35,9 +37,11 @@ YIELD path as <alias>
3537

3638
- `<WHERE clause>` filters properties of edges.
3739

38-
- `<N>` is the maximum hop number of the path. The default value is `5`.
40+
- `UPTO <N> {STEP|STEPS}` is the maximum hop number of the path. The default value is `5`.
41+
42+
- `ORDER BY $-.path` specifies the order of the returned paths. For information about the order rules, see [Path](https://github.com/vesoft-inc/nebula/blob/{{nebula.branch}}/src/common/datatypes/Path.h#L86).
3943

40-
- `<M>` specifies the maximum number of rows to return.
44+
- `LIMIT <M>` specifies the maximum number of rows to return.
4145

4246
!!! note
4347

@@ -75,6 +79,35 @@ nebula> FIND SHORTEST PATH WITH PROP FROM "team204" TO "player100" OVER * REVERS
7579
+--------------------------------------------------------------------------------------------------------------------------------------+
7680
```
7781

82+
```ngql
83+
nebula> FIND SHORTEST PATH FROM "player100", "player130" TO "player132", "player133" OVER * BIDIRECT UPTO 18 STEPS YIELD path as p;
84+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
85+
| p |
86+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
87+
| <("player100")<-[:follow@0 {}]-("player144")<-[:follow@0 {}]-("player133")> |
88+
| <("player100")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> |
89+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> |
90+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player109")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> |
91+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player104")-[:serve@20182019 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> |
92+
| ... |
93+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> |
94+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player109")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> |
95+
| ... |
96+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
97+
```
98+
99+
```ngql
100+
nebula> FIND SINGLE SHORTEST PATH FROM "player100", "player130" TO "player132", "player133" OVER * BIDIRECT UPTO 18 STEPS YIELD path as p;
101+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
102+
| p |
103+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
104+
| <("player100")<-[:follow@0 {}]-("player144")<-[:follow@0 {}]-("player133")> |
105+
| <("player100")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> |
106+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> |
107+
| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> |
108+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
109+
```
110+
78111
```ngql
79112
nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree is EMPTY or follow.degree >=0 YIELD path AS p;
80113
+------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)