cancel
Showing results forΒ
Did you mean:Β

## Does allshortestpath in gds can not outcome the links and nodes for each path?

Hi, I have a question about allshortestpath algorithm in gds.

When I run the query like this:

CALL gds.alpha.allShortestPaths.stream({
nodeQuery: 'MATCH (n:Loc) RETURN id(n) AS id',
relationshipQuery: 'MATCH (n:Loc)-[r:ROAD]-(p:Loc) RETURN id(n) AS source, id(p) AS target, r.cost AS cost',
relationshipWeightProperty: 'cost'
})
YIELD sourceNodeId, targetNodeId, distance
WITH sourceNodeId, targetNodeId, distance
WHERE gds.util.isFinite(distance) = true

MATCH (source:Loc) WHERE id(source) = sourceNodeId
MATCH (target:Loc) WHERE id(target) = targetNodeId
WITH source, target, distance WHERE source <> target

RETURN source.name AS source, target.name AS target, distance
ORDER BY distance DESC, source ASC, target ASC
LIMIT 10

I find that when I call the gds.alpha.allShortestPaths, the output is only sourceNodeId, targetNodeId and distance. Is it true? I want get the information of links and nodes for each path. Can I get them by calling gds?

6 REPLIES 6
Node Clone

It is not possible with that algorithm.
It all depends on your usecase.

Do you surely need all shortest paths for all pair of nodes?

Yes, I think so. Since I need to calculate some complex network indicators according to the information of links between each two node

I don't need all shortest paths for all pair of nodes, but for each node pair, I need the detail path of the shortest path, like which nodes this path across.

Node Clone

I think you can find some different solutions here: