Question

I'm trying to write a cypher query that allows me to search nodes from bottom to top. For example: I have a small affiliate network, in which Joe refers Mary, Mark and Bob. Mary, Mark and Bob have 10 children each. And their children, 10 each. I want to search this network by starting with the lowest tier of Joe, which means the children of the children of Mary, Mark or Bob.

Any ideas on how to achieve this? Get all the bottom nodes and then get back up?

Was it helpful?

Solution

There was just a LowestCommonAncestor Algo contributed by Pablo Pareja, see https://github.com/neo4j/community/commit/8919b28dfe523e843935a4bf70381498fd25875b . Is that what you want?

Otherwise, if you want to find all leave nodes in a network you can do this with Cypher like at http://tinyurl.com/c6kmcew (example):

start joe=node(1) match p=joe-[:refers]-referredPerson-[:parent_of*1..]->kid return kid, p

HTH

/peter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top