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.

Hi there:
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?

Thanks

Comments
mdfrenchman
Graph Voyager

You should be able to do:

MATCH (parent)-[:PARENT_OF]->(child) RETURN parent, collect(child) as children

OR

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 (parent)<-[:CHILD_OF]-(child)

Hope that helps,

Mike French

asha_sundararaj
Node Link

Hi Mike,
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"

asha_sundararaj
Node Link

Thanks Mike, your suggestion works.... Awesome

Version history
Last update:
‎06-19-2019 06:39 AM
Updated by:
Contributors