I am working on creating a dynamic family tree. I have all "parent-of" relationships in a single direction between parent and child.
Is there a way that I can query in the reverse from child to parent without creating a bi-directional relationship?
You should be able to do:
MATCH (parent)-[:PARENT_OF]->(child) RETURN parent, collect(child) as children
MATCH (parent)-[:PARENT_OF]->(child) RETURN child, collect(parent) as parents
depending on if you want the children per parent, or parents per child. You don't need an extra relationship pointing in the opposite direction
Hope that helps,
Thanks for the suggestion, but this is showing me the children related to the parent.
I am seeking the following query.
I have Grand-dad as "parent-of" dad, dad as "parent_of" grandchild relationship, which is unidirectional.
I am seeking a query that given grandchild, how do I reverse query to get back to grand-dad? Do I need to set up a bi-directional relationship such as "child-of"
Thanks Mike, your suggestion works.... Awesome