简体   繁体   English

neo4j cypher:查找带有没有特定传出关系的末端节点的所有路径吗?

[英]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.

相关问题 neo4j cypher - 如何查找与节点列表有关系的所有节点 - neo4j cypher - how to find all nodes that have a relationship to list of nodes 查找没有特定关系的节点(Cypher / neo4j) - Finding nodes that do not have specific relationship (Cypher/neo4j) Neo4j(密码):如何找到具有特定关系的所有节点? - Neo4j (cypher): How do I find all nodes with a specific relationship? neo4j返回根节点一次,以及json中的所有关系和端节点 - neo4j return root node once, and all relationships and end-nodes in json 在Neo4j中查找所有路径末尾而不是其他路径中的节点 - Find nodes in Neo4j that are at the end of all paths and not in another 在neo4j密码中找到一个节点及其所有传入和传出节点 - Find a node and all its incoming and outgoing nodes in neo4j cypher Neo4j/Cypher:具有关系属性过滤器的两个节点之间的所有路径 - Neo4j/Cypher: All paths between two nodes with a relationship property filter NEO4J Cypher查找具有多个关系计数的节点 - NEO4J Cypher find nodes with multiple relationship counts 是否可以找到关系连接的节点-Cypher Neo4J - Is it possible to find which nodes a relationship connects - Cypher Neo4J 如何在 Cypher Neo4j 中获取不包含(相关)具有特定属性的节点的所有节点 - How do I get all nodes that do not contain (relate) nodes with certain property in Cypher Neo4j
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM