This might work, but my dataset has about 2m nodes and it is very slow as it results a cartesian join:
MATCH (n), (p) WHERE n.name = 'A' AND p.name = 'A' AND NOT (p)-->(n) RETURN n On Tuesday, December 27, 2016 at 9:52:08 PM UTC+11, Behrang Saeedzadeh wrote: > > Hi Benoit, > > A is the value of the name property for the nodes. So the query is more > like this: > > > MATCH (n) > WHERE > size ((m)-->(n)) = 0 > AND m.name = 'A' > AND n.name = 'A' > RETURN n > > > However this won't work because I don't have m in the MATCH clause: > > Variable `m` not defined (line 3, column 9 (offset: 24)) > " size ((m)-->(n)) = 0" > ^ > > > > > On Saturday, December 24, 2016 at 9:33:47 PM UTC+11, Benoît Simard wrote: >> >> 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.
