我想回到所有节点一个和b,其中b不是通过与关系相对开始的任何路径一个下游。我不断发现自己不得不编写一个条件,其中一个通过相对,还有一个间接的情况下直接链接到b的情况下,导致了这样的事情:暗号:量化的零个以上的节点,然后-关系
//Semi-pseudo-code.
match (a)-[*]->(b)
optional match dir=(a)-[:rel]->(b)
optional match indir=(a)-[:rel]-()-[*]->(b)
where length(dir)=0
and length(indir)=0
return a,b
有更简单的方法?真的,我想是这样的,在这里裸量词表示“零个或多个节点,然后-关系”:
match (a)-[*]->(b)
match not (a)-[:rel]-*->(b)
return a,b
注:我怀疑这可能从根本是一样的我的最后一个问题:Cypher: Matching nodes at arbitrary depth via a strictly alternating set of relations
感谢您的回复。但是,您的代码是否仍然与直接案例相匹配?: (a) - [:rel] - >(b) 我需要排除该情况。 (或者我误解了?) –
好点 - [可变长度关系](https://neo4j.com/docs/developer-manual/current/cypher/#_variable_length_relationships)缺省为1的“minHops”值。I fixed该查询将在一分钟内添加一个示例。 –