diff --git a/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md b/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md index 90436d94991..e33e8eafdb2 100644 --- a/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md +++ b/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md @@ -9,7 +9,7 @@ The `FIND PATH` statement finds the paths between the selected source vertices a ## Syntax ```ngql -FIND { SHORTEST | ALL | NOLOOP } PATH [WITH PROP] FROM TO +FIND { SHORTEST | SINGLE SHORTEST | ALL | NOLOOP } PATH [WITH PROP] FROM TO OVER [REVERSELY | BIDIRECT] [] [UPTO {STEP|STEPS}] YIELD path as @@ -19,7 +19,9 @@ YIELD path as [vertex_id [, vertex_id] ...] ``` -- `SHORTEST` finds the shortest path. +- `SHORTEST` finds all the shortest path. + +- `SINGLE SHORTEST` finds the all shortest path. If there are multiple shortest paths, only one path is returned. - `ALL` finds all the paths. @@ -35,9 +37,11 @@ YIELD path as - `` filters properties of edges. -- `` is the maximum hop number of the path. The default value is `5`. +- `UPTO {STEP|STEPS}` is the maximum hop number of the path. The default value is `5`. + +- `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). -- `` specifies the maximum number of rows to return. +- `LIMIT ` specifies the maximum number of rows to return. !!! note @@ -75,6 +79,35 @@ nebula> FIND SHORTEST PATH WITH PROP FROM "team204" TO "player100" OVER * REVERS +--------------------------------------------------------------------------------------------------------------------------------------+ ``` +```ngql +nebula> FIND SHORTEST PATH FROM "player100", "player130" TO "player132", "player133" OVER * BIDIRECT UPTO 18 STEPS YIELD path as p; ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| p | ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| <("player100")<-[:follow@0 {}]-("player144")<-[:follow@0 {}]-("player133")> | +| <("player100")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player109")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player104")-[:serve@20182019 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> | +| ... | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player109")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> | +| ... | ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```ngql +nebula> FIND SINGLE SHORTEST PATH FROM "player100", "player130" TO "player132", "player133" OVER * BIDIRECT UPTO 18 STEPS YIELD path as p; ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| p | ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| <("player100")<-[:follow@0 {}]-("player144")<-[:follow@0 {}]-("player133")> | +| <("player100")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player114")<-[:follow@0 {}]-("player133")> | +| <("player130")-[:serve@0 {}]->("team219")<-[:serve@0 {}]-("player112")-[:serve@0 {}]->("team204")<-[:serve@0 {}]-("player138")-[:serve@0 {}]->("team225")<-[:serve@0 {}]-("player132")> | ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` + ```ngql nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree is EMPTY or follow.degree >=0 YIELD path AS p; +------------------------------------------------------------------------------+