We have a Neo4J database that tracks people working for companies. The general structure is -
(Person)-[:WORKS_AT]->(Company)
A person can have multiple jobs at the same time and each company can have multiple people.
Given 2 companies (Company 1 and Company 2) we can calculate the shortest path using -
match (start:Company {id:1}),(end:Company {id:2}), p = shortestPath((start)-[:WORKS_AT*]-(end)) return *
What we want to do, is calculate the shortest path between the 2 companies where the path includes specific people, e.g. -
(Company 1)-(Person 1)-(Company 4)-(Person 2)-(Company 2)
would be returned instead of the following if we wanted to connect via Person 2 -
(Company 1)-(Person 3)-(Company 2)