Reputation: 374
I have group node structure where a node inherits permissions from previous node
Manager ---Implies---> PowerUser ---Implies---> User
But the structure is not clean and sometimes i have 2 edges from manager to poweruser and again to user which is already implied by poweruser
Manager ---Implies---> PowerUser ---Implies---> User
---Implies----------------------------> User
How can i query nodes to dectect that i already have a implicit relation and that i don't need the extra explicit relation
Upvotes: 1
Views: 50
Reputation: 466
It looks like PowerUser
is a label in your structure. You can write a variable-length traversal [1] that considers paths of any length so long as this label appears somewhere:
MATCH (entity)-[*0..]->(:PowerUser)
Would be the broadest traversal to accomplish this, matching any node connected to the PowerUser
label by 0 or more edges.
Given that PowerUser
is a permission, however, it seems like a more appropriate design would be to treat it as a property. Since Cypher is schema-less, properties are not scoped to specific labels, so it can be set and filtered on nodes with the Manager
or User
labels. This approach would allow more succinct expressions like:
MATCH (entity {PowerUser: true})-[]->()
If this doesn't match your use case, feel free to provide more details about your graph structure!
Upvotes: 1