KWriter
KWriter

Reputation: 1180

Does counting hops start from zero of from one?

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.

Upvotes: 0

Views: 88

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14391

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

Upvotes: 1

Related Questions