Reputation: 867
using neo4j I'm trying to find max depth in this graph:
Using this query I find deph value 20 (because I have this bidirectional relationship):
MATCH p=(u:User)-[:Amico*]->(f:User)
RETURN p, length(p) order by length(p) desc limit 1
How can I have the true value of this depth?
Upvotes: 0
Views: 166
Reputation: 5385
I guess you could solve it by only considering paths in which each node only appears once. Neo4j's apoc library offers a function for that:
MATCH p=(u:User)-[:Amico*]->(f:User)
WHERE NOT apoc.coll.containsDuplicates(nodes(p))
RETURN p, length(p) order by length(p) desc limit 1
Upvotes: 1