I'm trying to get the all the intermediate nodes between two nodes in a graph using Neo4j CYPHER.
A sample result would be.
- Path between 1 and 4 should return 1, 2, 3 and 4.
- Path between 1 and 3 should return 1, 2 and 3.
- Path between 4 and 6 should return 4, 5 and 6.
- Path between 1 and 6 should return 1, 2, 3, 4, 5 and 6.
The path between 1,2,3 and 4 has the combined distance as to 1 and 4 directly. 4 to 6 would have the same distance as 4,5,6.
Alternatively, a cypher query to remove the shortcuts if a longer route is available.
I've tried a standard path finding command but that returns 1 and 4 each time.:
MATCH path = shortestpath((s:Node{ Id: 1})-[Link*]->(e:Node {Id: 4}))
RETURN path LIMIT 1
public class Node {
public long Id {get;set;}
}
public class Link {
}
Thank you.
