I am trying to create a cypher statement for finding root nodes a
from a given node n
in a hierarchical graph structure, where some nodes are "deactivated", meaning the node itself and all connected relationships have a property deactivated
with a date as value.
I am able to find the root node when also traversing deactivated nodes:
MATCH (a)-[rs:child*]->(n)
WHERE NOT ()-[:child]->(a) AND id(n) = $n_id
RETURN DISTINCT a
I imagine I have to somehow unwind the relationships rs
and filter on exists(r.deprecated)
.
Another solution would be similar to what is found in the neo4j developer manual (v3.4) under "7.1.4. Relationships in depth - Match with properties on a variable length path":
MATCH p =(charlie:Person)-[* { blocked:false }]-(martin:Person)
I was hoping for a solution where instead of having to explicitly define a property deactivated:false
for all non-deactivated relationships, it would ignore relationships with a nonzero deactivated
property.
Are any of these solutions possible?