cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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

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

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
...