Something like that ?

MATCH (n:A)
WHERE
  size((:A)-->(n)) = 0 AND
 exists((:Root)-[*]->(n))
RETURN n



2016-12-24 10:40 GMT+01:00 Behrang Saeedzadeh <[email protected]>:

> Let's pretend we have a tree like this in which each node is labeled with
> the name property:
>
>
> ROOT
> |
> \---> X --> *A* --> Y --> A --> Z
> |
> |
> \---> *A* --> A
> |
> |
> \---> *A*
>
>
> I want to return all the nodes named A that don't have an ancestor that is
> also named A. In other words, only the *A* nodes that are in bold and are
> underlined.
>
> What Cypher query can return these nodes?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to