I am using below two different approaches to come up with the shortest paths across all target and source combinations. I have 64 gbs of memory and am expecting "all shortest paths" to take shorter; however, iterating through Djikstra single source algorithm for each node somehow works faster than that algo.
I'm wondering if I'm doing something wrong... Any help would be appreciated.
- All Shortest Paths:
CALL gds.alpha.allShortestPaths.stream('cypherGh3', {
relationshipWeightProperty: 'cost',
concurrency : 4
})
YIELD sourceNodeId, targetNodeId, distance
WITH sourceNodeId, targetNodeId, distance
MATCH (source:Loc) WHERE id(source) = sourceNodeId
MATCH (target:Loc) WHERE id(target) = targetNodeId
WITH source, target, distance
WHERE source <> target
AND source.name STARTS WITH 'BIN'
AND target.name STARTS WITH 'BIN'
RETURN source.name AS source, target.name AS target, distance
ORDER BY distance DESC, source ASC, target ASC
- Djikstra single source shortest path (repeated for all source nodes):
CALL gds.alpha.allShortestPaths.stream('cypherGh3', {
relationshipWeightProperty: 'cost',
concurrency : 4
})
YIELD sourceNodeId, targetNodeId, distance
WITH sourceNodeId, targetNodeId, distance
MATCH (source:Loc) WHERE id(source) = sourceNodeId
MATCH (target:Loc) WHERE id(target) = targetNodeId
WITH source, target, distance
WHERE source <> target
AND source.name STARTS WITH 'BIN'
AND target.name STARTS WITH 'BIN'
RETURN source.name AS source, target.name AS target, distance
ORDER BY distance DESC, source ASC, target ASC