1

Regarding this excerpt of cyper request: (assuming element is a known node variable in the whole request)

MATCH p = shortestPath(element-[:LINKS*..3]-(user))
RETURN length(p)

Assuming that one element might be a user, how could I prevent retrieving in the result the element representing the user itself?

It would be cool if we could do:

MATCH p = shortestPath(element-[:LINKS*1..3]-(user))
RETURN length(p)

But it leads to this error:

shortestPath(...) does not support a minimal length

What is the most efficient way to achieve this trick?

1 Answer 1

5

How about this:

MATCH p = shortestPath((element)-[:LINKS*..3]-(user))
WHERE element <> user
RETURN length(p)
1
  • Cool, that was so simple ;) Thanks
    – Mik378
    Mar 22, 2014 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.