cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to match a path, by stop by a condition

Hello!
I have a graph: root(neo4j id : 0) -[:include]-> childA(neo4j id 1) -[:include]-> childAA(neo4j id 2) -[:include]-> childAAA(neo4j id 3)
I want match from childAAA reversely along include edge, but stop when the endNode of current edge in node set [0, 1]. In other words root->childA is not in result, but childA->childAA should be in.

I don't know how to write the cypher statement. I'm looking forward to help!
Thanks a lot!

2 REPLIES 2

ameyasoft
Graph Maven
You can start from childA(neo4j id 1).

//insert correct node info.....
MATCH childA(neo4j id 1)
CALL apoc.path.subgraphNodes(a, {relationshipFilter:'include>'}) 
YIELD node
RETURN node

This should give you the desired result.
 

Thank you! I get the method also:
match p = (n)<-[r:include*..]-() where id(n)=3 AND not id(nodes(p)[-1]) in [0, 1] return p