简体   繁体   English

Cypher:找到连接父节点的节点关系

[英]Cypher: Find relationships of nodes with connected parents

I'm hoping this diagram will be sufficient to explain what I'm after: 我希望这个图表足以解释我所追求的内容:

                   true
          a--------------------b
          |                    |
   parent |                    | parent
          |                    |
         a_e------------------b_e
               experimental

nodes a_e and b_e are experimental observations that each have only one parent, a and b, respectively. 节点a_e和b_e是实验观察,每个节点只有一个父节点a和b。 I know a true relationship exists between a and b, and I want to find cases where experimental relationships were observed between a_e and b_e. 我知道a和b之间存在真正的关系,我想找到在a_e和b_e之间观察到实验关系的情况。 Among other things, I tried the following: 除其他外,我尝试了以下方法:

 MATCH (n)-[:true]-(m)
 WITH n,m
 MATCH (n)-[:parent]-(i)
 MATCH (m)-[:parent]-(j)
 WITH i,j
 OPTIONAL MATCH (i)-[r]-(j)
 RETURN r

but this returns no rows. 但是这不会返回任何行。 I'm thinking of this like a nested loop, matching all possible relationships between all i's and all j's. 我认为这就像一个嵌套循环,匹配所有i和所有j之间的所有可能的关系。 Is this type of query possible? 这种查询是否可行?

Something like 就像是

match (n)-[:true]-(m) 
match (n)-[:parent]->(n_child)-[:experimental]-(m_child)<-[:PARENT]-(m) 
return  n_child,m_child

(not tested) (未测试)

Assuming this is an example and you have labels etc. on your nodes. 假设这是一个示例,并且您的节点上有标签等。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM