cancel
Showing results for 
Search instead for 
Did you mean: 

In Match with hops query[Follows*1..3], what query can give me the degrees of separation in the response?

asha_sundararaj
Node Link

In Match with hops query[Follows*1..3], what query can give me the degrees of separation in the response?

I am working on a force-graph in react with a node/express api. I would like to see the actual degree of separation, 1st level, second level, etc.

2 REPLIES 2

Cobra
Ninja
Ninja

Hello @asha.sundararajan

I guess you are looking for the length() function.

Regards,
Cobra

As Cobra mentioned, length(path) is what you're looking for, but this requires that you add a path variable into your MATCH. Something like:

MATCH path = (user1:User {id:12345})-[Follows*1..3]-(user2)
WITH user1, user2, length(path) as pathLength
...
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.