1
votes

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. 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. 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. Is this type of query possible?

1
The query seems to be working actually.Rahul Govind

1 Answers

3
votes

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.