0

When counting hops, has the first node (the one that is directly connected) the distance of one hop or zero hops?

For example, in this code will return the results when the path is equal to or shorter than 3 hops:

MATCH path=(n {id: 0})-[relationships * ..3]->(m {id: 8}) 
RETURN path,relationships;

So is this actually A->B->C->D or A->B->C. What is defined as hop, number of nodes or relations that are traversed?

I couldn't find this information anywhere.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
KWriter
  • 1,024
  • 4
  • 22
  • Please share more details, like the code involved that helps others to understand your problem. What keeps you from running the code on a sample input and check the output? – Nico Haase Dec 07 '22 at 16:15
  • This is a theoretical question. I'm trying to figure out what the hop means. – KWriter Dec 12 '22 at 17:05

1 Answers1

1

The variable length path pattern, *..3 is the same as 1..3 which means at least one hop, and at most 3. So this allows for any of:

A,B
A,B,C
A,B,C,D

This behavior is documented starting on page 11 of the openCypher specification that is available here

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38