I have a sample graph as depicted below.
The nodes have the following labels:
- node (a) has label
User - nodes (b) until (g) have label
Attribute - nodes (h) and (i) have label
Object
Node (a) has a relationship to (d) and also to (e)
I want to check which of the Object nodes (h) and (i) have relationships to all of the Attribute nodes that the user is connected to, i.e. (d) and (e).
So
- node (h) has a relationship to (d) AND to (e) --> this is ok
- node (i) only has a relationship to (e) --> this is not ok
How would I detect this in a Cypher query?
I started with something like:
MATCH p1 = (u:User)-->(ua:Attribute)-->(oa:Attribute)
WITH *
MATCH p2 = (oa)<-[*]-(o:Object)
RETURN p1,p2
This gives me the complete graph. But how do I refine this to get only (h) back and not (i).
I guess I will have to build a list of results from the first part and validate if a relation exist to all of these?