I am trying to build a cypher statement for neo4j where I know 2-n starting nodes by name and need to find a node (if any) that can be reached by all of the starting nodes.
At first I tought it was similar to the "Mutual Friend" situation that could be handled like
(start1)-[*..2]->(main)<-[*..2]-(start2)
but in my case I often have more then 2 starting points up around 6 that I know by name.
So basically I am puzzled by how i can include the third, fourth and so on node into the cypher to be able to find a commmon root amongst them.
In the above Example from the neo4j Website I would need a path starting with 'Dilshad', 'Becky' and 'Cesar' to check if they have a common friend (Anders) excluding 'Filipa' and 'Emil' as they are not friends of all three.
So far I would create a statement programmatically that looks like
MATCH (start1 {name:'Person1'}), (start2 {name:'Person2'}),
(start3 {name: 'Person3'}), (main)
WHERE (start1)-[*..2]->(main) AND
(start2)-[*..2]->(main) AND
(start3)-[*..2]->(main) RETURN distinct main
But I was wondering if there is a more elegant / efficient way in cypher possibly where I could use the list of names as parameter