简体   繁体   English

从Neo4j Cypher allShortestPaths()中排除包含给定节点或给定关系的路径

[英]Excluding paths from Neo4j Cypher allShortestPaths() that contain a given node, or given relationship

What is the best way, given the following Neo4j Cypher query, for the returned collection of paths not to contain any path that contains an Item node whose itemId is equal to “Q5”? 给定以下Neo4j Cypher查询,对于返回的路径集合不包含任何包含itemId等于“ Q5”的Item节点的路径,最佳方法是什么?

MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) ) 
RETURN p;

Also, what is the best way, given the above query, for the returned collection of paths not to contain any path that contains a relationship whose propId is equal to “P31”? 另外,给定上述查询,对于返回的路径集合不包含任何包含其propId等于“ P31”的关系的路径,最好的方法是什么?

Thanks, James Weaver 谢谢,詹姆斯·韦弗

  1. The returned collection of paths does not contain any path that contains an Item node whose itemId is equal to “Q5”: 返回的路径集合不包含任何包含itemId等于“ Q5”的Item节点的路径:

     MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) ) WHERE NONE(x IN NODES(p) WHERE x:Item AND x.itemId = "Q5") RETURN p; 
  2. The returned collection of paths does not contain any path that contains a relationship whose propId is equal to “P31”: 返回的路径集合不包含任何包含其propId等于“ P31”的关系的路径:

     MATCH p=allShortestPaths( (a:Item {itemId:"Q6294"})-[*]-(b:Item {itemId:"Q359442"}) ) WHERE NONE(x IN RELATIONSHIPS(p) WHERE x.propId = "P31") RETURN p; 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Neo4j:密码计算从allShortestPaths找到的总路径? - Neo4j: Cypher count total paths found from allShortestPaths? Neo4j密码查询:具有指定节点和关系属性的AllShortestPaths - Neo4j cypher query: AllShortestPaths with specified nodes and relationship properties 用Neo4j Cypher查找给定长度以下的路径,但排除那些将其特定属性设置为特定值的节点的路径 - Finding Paths with Neo4j Cypher Below a Given Length, but Excluding Those with an Nodes with a Specific Property set to a Specific Value Neo4j Cypher 从同一节点查询多个关系 - Neo4j Cypher Query multiple relationship from same node Neo4j-密码节点和关系关系 - Neo4j - Cypher node and relationship relation Neo4j Cypher:shortestPath 和 allShortestpaths 之间的区别 - Neo4j Cypher: Difference between shortestPath and allShortestpaths Neo4j:从给定的起始节点查找涉及所有关系的所有路径 - Neo4j: From given start node find all paths that touch all relations Neo4j cypher计算并显示两个给定节点之间的所有关系 - Neo4j cypher to count and display all the relationship between two given nodes 如何使用cypher在Neo4j中给出它们的属性来创建两个节点之间的关系 - How to use cypher to create relationship between two nodes given their attributes in Neo4j Neo4j cypher如何在APOC neo4j cypher查询中包含父对象的另一个关系节点 - Neo4j Cypher how to include another relationship node of parent in APOC neo4j cypher query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM