Skip to content

Commit bccc63e

Browse files
authored
add note explaining last(rel) (#1340)
1 parent 9976e77 commit bccc63e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pages/advanced-algorithms/deep-path-traversal.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ MATCH path=(n {id: 0})-[* (r, n, p | r.eu_border = false AND n.drinks_USD < 15 A
194194
RETURN path;
195195
```
196196

197+
**Note:** `last(relationships(p))` returns the most recent relationship in the
198+
current traversal path p, allowing you to filter based on how the current node
199+
was reached.
200+
197201
## Breadth-first search
198202

199203
In breadth-first search (BFS) traversal starts from a single node, and the order of
@@ -348,6 +352,10 @@ MATCH path=(n {id: 0})-[*BFS (r, n, p | r.eu_border = false AND n.drinks_USD < 1
348352
RETURN path;
349353
```
350354

355+
**Note:** `last(relationships(p))` returns the most recent relationship in the
356+
current traversal path p, allowing you to filter based on how the current node
357+
was reached.
358+
351359
## Constraining the expansion based on the number of hops
352360

353361
### Overview
@@ -641,6 +649,10 @@ MATCH path=(n {id: 0})-[*WSHORTEST (r, n | n.total_USD) total_weight (r, n, p, w
641649
RETURN path, total_weight;
642650
```
643651

652+
**Note:** `last(relationships(p))` returns the most recent relationship in the
653+
current traversal path p, allowing you to filter based on how the current node
654+
was reached.
655+
644656
## All shortest paths
645657

646658
Finding all shortest paths is an expansion of the weighted shortest paths problem. The goal
@@ -779,4 +791,8 @@ MATCH path=(n {id: 0})-[*ALLSHORTEST (r, n | n.total_USD) total_weight (r, n, p,
779791
RETURN path, total_weight;
780792
```
781793

794+
**Note:** `last(relationships(p))` returns the most recent relationship in the
795+
current traversal path p, allowing you to filter based on how the current node
796+
was reached.
797+
782798
<CommunityLinks/>

0 commit comments

Comments
 (0)