FIND PATH¶
FIND { SHORTEST | ALL | NOLOOP } PATH FROM <vertex_id_list> TO <vertex_id_list>
OVER <edge_type_list> [REVERSELY | BIDIRECT] [UPTO <N> STEPS] [| ORDER BY $-.path] [| LIMIT <M>]
<vertex_id_list> ::=
[vertex_id [, vertex_id] ...]
The FIND PATH
statement finds the paths between the selected source vertices and destination vertices.
SHORTEST
finds the shortest path.ALL
finds all the paths.<vertex_id_list>
is a list of vertex IDs separated with commas (,). It supports$-
and$var
.<edge_type_list>
is a list of edge types separated with commas (,).*
is all edge types.<N>
is the hop number. The default value is 5.<M>
specifies the maximum number of rows to return.
Limitations¶
- When a list of source and/or destination vertex IDs are specified, the paths between any source vertices and the destination vertices is returned.
- There can be cycles when searching all paths.
FIND PATH
does not support filtering withWHERE
clauses.FIND PATH
does not support specifying a direction.FIND PATH
is a single-thread procedure, so it uses much memory.- If
NOLOOP
is not used,FIND PATH
can retrieve paths containing cycles. IfNOLOOP
is used,FIND PATH
can retrieve paths without cycles.
Examples¶
In Nebula Console, a path is shown as vertex_id <edge_name, rank> vertex_id
.
nebula> FIND SHORTEST PATH FROM "player102" TO "team201" OVER *;
+------------------------------------------------------------------+
| path |
+------------------------------------------------------------------+
| ("player102")-[:follow@0]->("player101")-[:serve@0]->("team201") |
+------------------------------------------------------------------+
nebula> FIND SHORTEST PATH FROM "team200" TO "player100" OVER * REVERSELY;
+---------------------------------------+
| path |
+---------------------------------------+
| ("team200")<-[:serve@0]-("player100") |
+---------------------------------------+
nebula> FIND ALL PATH FROM "player100" TO "team200" OVER *;
+---------------------------------------+
| path |
+---------------------------------------+
| ("player100")-[:serve@0]->("team200") |
+---------------------------------------+
nebula> FIND NOLOOP PATH FROM "player100" TO "team200" OVER *;
+---------------------------------------+
| path |
+---------------------------------------+
| ("player100")-[:serve@0]->("team200") |
+---------------------------------------+
Last update: April 1, 2021