Reputation: 131
I have a situation where a node has outward relationships to multiple nodes. These children in turn can have outward and inward relationship to other nodes until you reach the leaf nodes.
Is there a good way to write a cypher query where based on a starting node, I can traverse to the nodes children, then to their related (inward and outward) nodes and so on until I reach the leaves. The result should return all the relationships and nodes found. Thanks in advance.
Upvotes: 0
Views: 552
Reputation: 638
Maybe this is too greedy but you can try
START a=node(id) //replace with the id of the node you want to start
MATCH p=a-[r*]->x //get all the paths to all nodes
WHERE NOT(x-->()) //exclude nodes with Direction Out Relationships
RETURN p,a,x,r //return whatever you need
Upvotes: 0