I want to use cypher to get to the following result: "Find all paths starting from node A only following relationships on which the property "percentage" 1 is greater 50 and the end of path is a node with property 'type' = 1 and the end of path has no further relationships as specified before (percentage>50 ...)"
( 1 : I'm considering to create a separate relationship-type "MY_RELATIONSHIP_50" for performance reasons)
My Cypher works fine so far:
start A = node(...)
match path = (A)-[rels:MY_RELATIONSHIP*]->(B)
where all(rel in rels where rel.percentage! > 50) and B.type = 1
return path
But I can't find a way to express " the end of path has no further relationships as specified before (percentage>50 ...)
"
I tried to extend the where clause with " and not B-->C
" but I did neither find out how to qualify with percentage > 50
.
Is there a way to do this?
Thank's a lot in advance =)
You are kind of looking for the longest path?
So either just sort descending by length and take the top n.
Otherwise something like:
start A = node(...)
match path = (A)-[rels:MY_RELATIONSHIP*]->(B)
where all(rel in rels where rel.percentage! > 50) and B.type = 1
AND NONE(r in extract(p in (B-[:MY_RELATIONSHIP]->()) : head(rels(p)) WHERE r.percentage > 50)
return path
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.