hi ,
I use the Dijkstra Source-Target algorithm to find the weighted shortest path via the cypher code below.
However, the result still shows the unweighted shortest path even after I added the "relationshipWeightProperty" in my cypher "call" query. Please give some advise for how to get the weighted shortest path, thanks.
the link for data and code as below:
MATCH (source:Place {id:'Amsterdam'}),(target:Place {id:'London'})
CALL gds.shortestPath.dijkstra.stream({nodeProjection:'Place',relationshipProjection:'EROAD',relationshipProperties:'distance',sourceNode:source,targetNode:target,relationshipWeightProperty:'distance'})
YIELD nodeIds,costs
WITH [nodeId in nodeIds|gds.util.asNode(nodeId).id] AS nodeName,costs AS costs, size(nodeIds) AS siz
UNWIND range(0,siz-1) AS n
RETURN nodeName[n] AS city, costs[n] AS step
path of result generated by code above is still "Amsterdam-Immingham-Doncaster-London" same as unweighted path. The weighted path should be "Amsterdam-Den Haag-Hoek van Holland-Felixstowe-Ipswich-Colchester-London". this example in the book is represented by algo lib but this lib is retired so I use the GDS lib to rewrite the example. It seems the GDS lib not work well
MATCH (source:Place {id: "Amsterdam"}), (destination:Place {id: "London"})
CALL gds.shortestPath.dijkstra.stream('g1',{
sourceNode: source,
targetNode: destination,
relationshipWeightProperty: 'distance'
})
YIELD nodeIds, costs
WITH [nodeId in nodeIds|gds.util.asNode(nodeId).id] AS nodeName,costs AS costs, size(nodeIds) AS siz
UNWIND range(0,siz-1) AS n
RETURN nodeName[n] AS city, costs[n] AS step