[英]neo4j cypher: find all paths with end-nodes that do not have a certain outgoing relationship?
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 ...)" 我想使用cypher来获得以下结果:“仅在属性“ percentage” 1大于50并且路径结尾为属性“ type” = 1的节点上找到从节点A开始的所有路径。路径的末尾没有以前指定的其他关系(百分比> 50 ...)“
( 1 : I'm considering to create a separate relationship-type "MY_RELATIONSHIP_50" for performance reasons) ( 1 :出于性能原因,我正在考虑创建一个单独的关系类型“ MY_RELATIONSHIP_50”)
My Cypher works fine so far: 到目前为止,我的Cypher工作正常:
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 ...)
" 但是我找不到一种表达方式“ 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
. 我试图用“ and not B-->C
”扩展where子句,但是我都没有找到如何用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. 因此,要么按长度降序排序,然后取前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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.