A cypher subquery on each node in the path

In this diagram, I would like to find the whole circle of gray nodes in the red bubble, and not in other gray nodes. That is, all nodes labeled: OTHER, which are auxiliary nodes of nodes on the path between A and C. NB. The path between A and C can be longer than the three nodes listed here.

enter image description here

So what I want to do is get the path p = A ... C and the subquery of each node in the path for the relation [-. HAS] → (n: OTHER).

However, I am stuck in a subquery because it does not affect the result set of the original query, but rather on all nodes.

So this gives me all the gray nodes :( and not just the ones in the red bubble. Please help

match p=(n:MAIN)-[:EXTENDS*]->(m:MAIN) 
where n.name = 'A' AND m.name='C' 
WITH nodes(p) AS collection 
match (l:MAIN)-[:HAS]->(u:OTHER) return u;  //This last part is my subquery
+3
source share
1 answer

"MATCH" , .

A-B (, "" ), ,

MATCH p=(n:MAIN)-[:EXTENDS*0..]->(middle:MAIN)-[:EXTENDS*0..]->(m:MAIN)  
WHERE n.name = 'A' AND m.name='C' 
WITH middle
MATCH (middle:MAIN)-[:HAS]->(u:OTHER)
RETURN u
+9

All Articles