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.
SHORTESTfinds the shortest path.ALLfinds 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 PATHdoes not support filtering withWHEREclauses.FIND PATHdoes not support specifying a direction.FIND PATHis a single-thread procedure, so it uses much memory.- If
NOLOOPis not used,FIND PATHcan retrieve paths containing cycles. IfNOLOOPis used,FIND PATHcan 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