Tobias Gassmann
Tobias Gassmann

Reputation: 11819

Cypher: Find shortest path between two nodes identified by their IDs

Is this cypher-query correct? I am trying to find the shortest path between two nodes based on the node-IDs:

MATCH (martin:RoadNode {id:16814}),(oliver:RoadNode {id:16820}),
p = shortestPath((martin)-[*..15]-(oliver))
RETURN p

It does execute without error, but it returns 0 rows, although I expect it to find a path.

Upvotes: 3

Views: 10869

Answers (1)

Tobias Gassmann
Tobias Gassmann

Reputation: 11819

I have found it! In order to find the shortest path between to nodes based on their IDs, this cypher-query does the trick:

MATCH (martin:RoadNode),(oliver:RoadNode),
p = shortestPath((martin)-[*..15]-(oliver)) 
WHERE id(martin) = 16814 AND id(oliver) = 16820
RETURN p

Upvotes: 10

Related Questions