I wonder if there is a more elegant way to find nodes which are not linked to other specific nodes.
nodes in darker green are "regions"
nodes in lighter green are "countries"
there can be a mix of children, with both "regions" and "countries"
all relationships are of the same type ("rel")
I would like to extract the end region nodes (those regions) which only contain countries underneath, and I thought to be a no-brainer...silly me.
Eventually, this worked, but i do not like it:
with w optional match (w)-[r]->(i:Region)
with w, collect(r.acr) as p where size(p)=0
Note:r.acr is just some random property which i have been using with collect
I was expecting something like "optional match (e:Region) where not( (e)--(e1:Region) )but as e1 needs to be declared prior to "where", it creates a cartesian product in which, of course, if finds some regions which are not directly linked.
Also tried the count directly in where