As Neo4j doesn't allow relationships having no direction. We modelled relationships that are naturally not having any direction, in some arbitrary direction.
(p1:Person)-[team_member_of]->(p2:Person)
(p1:Person)<-[team_member_of]<-(p3:Person)
While querying, i want to know all team members of p1. That can be done
MATCH(p1:Person)-[team_member_of]-(Person)
WHERE id(p1) = someId
For this relationship type it make sense to travese in both directions. There are other relationship types say
(p1:Person)-[driver_of]->(p2:Person)
(p1:Person)<-[driver_of]-(p3:Person)
While querying, i want to know all drivers of p1. That can be done
MATCH(p1:Person)<-[driver_of]-(Person)
WHERE id(p1) = someId
In this case, we need to query in only one direction.
In order to distinguish these two use cases, we have added a property on each relationship. saying directed: true/false (This is kind of defeating the purpose why neo4j doesn't allow relationships without direction.)
I can't think of any other way to find out if the relationship is really has direction / directionless
Any thoughts on how to do it in a nice way?
directed: true/falserelationship property? - Bruno Peres