I currently have a Neo4J Graph Database that stores 4 different kind of nodes that are connected via edges. Yellow/Red nodes that are connected to blue nodes and the yellow/red nodes have green nodes connected that give additional info on them.
What I want to do is to check if the selected node(either yellow or red) has a neighbor that is connected via the blue node, has a subset of common connected green nodes.
For example if I select the lower red node the upper red node would be returned as they both share the same far left green node neighbor which is a subset of the green node neighbors of the selected red node.
I currently have the following Cypher query, where the table nodes are the yellow and red nodes and the keyNode are the green nodes. The blue node is the objectType.
MATCH(table:TABLE)
where table.Name = $name
MATCH (table)-[keyRel:IS_DEFINED_BY_KEY]->(keyNode)
MATCH (table)<-[createRel:IS_CREATED_IN]-(objectType)-[createRel2:IS_CREATED_IN]->(createTables)
MATCH (createTables)-[keyRel2:IS_DEFINED_BY_KEY]->(addKey)
So at the end of the current query I have the searched/selected table, its neighboring green nodes, the yellow/red nodes that are connected via the blue node and the green nodes that are connected to them.
With that I now want to only return the connected yellow/red nodes that are connected to a subset of green nodes. So in the example only the upper red node.
Has anybody an idea how I can achieve this?