I want to write a query that returns node (a), nodes that are in close proximity to it (b), and then all nodes that connect to (b), but not those nodes that have already been defined as (b) .
So ... If my schedule were:
d
/
a<--b
\
c
I want to return {a, [b], [c, d]}.
So far I have the following request (the 'prop' attribute distinguishes each node from each other):
MATCH (a)<-[:something]-(b)<-[:something*0..]<-(c)
WHERE NOT (c.prop IN b.prop)
RETURN a.prop, collect(b.prop), collect (c.prop)
If my chart looks like this:
a<--b
I expect the result to be {a, [b], []}, but instead I get nothing, most likely due to the fact that c.prop is in b.prop. I tried using OPTIONAL MATCH, but that didn't work either:
MATCH (a)<-[:something]-(b)
OPTIONAL MATCH (a)<-[:something]<-(b)<-[:something*0..]<-(c)
WHERE NOT (c.prop IN b.prop)
RETURN a.prop, collect(b.prop), collect (c.prop)
How to get the expected results?
source
share