You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/queries/basic.adoc
+25-14Lines changed: 25 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -795,32 +795,43 @@ LIMIT 5
795
795
|===
796
796
797
797
[NOTE]
798
-
====
799
798
The quantifier used in the above two examples was introduced with the release of xref::patterns/variable-length-patterns.adoc#quantified-path-patterns[quantified path patterns] in Neo4j 5.9.
800
799
Before that, the only way in Cypher to match paths of a variable length was with a variable-length relationship.
801
-
This syntax is still available in Cypher.
802
-
Read more about it xref::patterns/reference.adoc#variable-length-relationships[here].
803
-
====
800
+
This syntax is still available in Cypher, but it is not xref:appendix/gql-conformance/index.adoc[GQL conformant].
801
+
For more information, see xref::patterns/reference.adoc#variable-length-relationships[Patterns -> Syntax and semantics -> Variable length relationships].
804
802
805
-
To find the shortest possible path between two nodes, use the `shortestPath` algorithm.
806
-
For example, this query matches the shorest path in the graph between the two nodes `Tom Hanks` and `Keanu Reeves`:
803
+
The xref:patterns/shortest-paths.adoc[`SHORTEST`] keyword can be used to find a variation of the shortest paths between two nodes.
804
+
In this example, `ALL SHORTEST` paths between the two nodes `Keanu Reeves` and `Tom Cruise` are found.
805
+
The xref:functions/aggregating.adoc#functions-count[`count()`] function calculates the number of these shortest paths while the xref:functions/scalar.adoc#functions-length[`length()`] function calculates the length of each path in terms of traversed relationships.
It shows that `Keanu Reeves` `ACTED_IN` the `Movie` `The Replacements`, which was `REVIEWED` by the movie critic `Jessica Thompson`, who also `REVIEWED` the `Movie` `The Da Vinci Code` which `Tom Hanks` `ACTED_IN`.
822
+
| 2
823
+
| 4
824
+
825
+
2+d|Rows: 1
826
+
827
+
|===
828
+
829
+
[NOTE]
830
+
The `SHORTEST` keyword was introduced in Neo4j 5.21, and functionally replaces and extendes the `shortestPath()` and `allShortestPaths()` functions.
831
+
Both functions can still be used, but they are not xref:appendix/gql-conformance/index.adoc[GQL conformant].
832
+
For more information, see xref:patterns/reference.adoc#shortest-functions[Patterns -> Syntax and semantics -> The `shortestPath()` and `allShortestPaths()` functions].
822
833
823
-
More information can be found in the section on xref::patterns/index.adoc[Patterns].
834
+
For more information about graph pattern matching, see xref::patterns/index.adoc[Patterns].
Copy file name to clipboardExpand all lines: modules/ROOT/pages/queries/concepts.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,13 +71,13 @@ This example uses a xref:patterns/variable-length-patterns.adoc#quantified-relat
71
71
The xref:syntax/operators.adoc#syntax-using-the-distinct-operator[DISTINCT] operator is used to ensure that the `RETURN` clause only returns unique nodes.
72
72
73
73
Paths can also be assigned variables.
74
-
For example, the below query binds a whole path pattern, which matches the xref:patterns/reference.adoc#shortest-functions[shortest path] from `Anna` to another `Person` node in the graph up to `10` hops away with the `nationality` property set to `Canadian`.
74
+
For example, the below query binds a whole path pattern, which matches the xref:patterns/shortest-paths.adoc[`SHORTEST`] path from `Anna` to another `Person` node in the graph with a `nationality` property set to `Canadian`.
75
75
In this case, the `RETURN` clause returns the full path between the two nodes.
76
76
77
77
[source, cypher]
78
78
----
79
-
MATCH p=shortestPath((:Person {name: 'Anna'})-[:KNOWS*1..10]-(:Person {nationality: 'Canadian'}))
79
+
MATCH p = SHORTEST 1 (:Person {name: 'Anna'})-[:KNOWS]-+(:Person {nationality: 'Canadian'})
80
80
RETURN p
81
81
----
82
82
83
-
For more information about graph patterns, see the section on xref:patterns/index.adoc[].
83
+
For more information about graph pattern matching, see xref:patterns/index.adoc[].
0 commit comments