Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-30-2021 12:54 PM
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?
Many thanks for your help.
01-02-2022 02:45 AM
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?
01-03-2022 04:12 AM
Thanks for your reply.
Yes, I think so. Since I need to calculate some complex network indicators according to the information of links between each two node
01-03-2022 05:15 AM
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.
01-03-2022 07:30 AM
I think you can find some different solutions here:
01-03-2022 09:45 AM
Thank you for your help.
Yes, according to this post, I have similar scenario with tenkaleakshay94, but in the case first. That is, I need the shortest path to every label2 node.
So now, I have a large network and I need to get the shortest path information for all node pairs.
But it is too much time consuming.
So I am looking for methods can improve the performance.
Do you have any ideas about how to improve the query performance?
01-03-2022 11:06 PM
Without knowing you real usecase I'm not sure I can help you with the performance problem.
When running an algorithm to get all nodepairs shortest paths will take alot of time to perform. Because it will traverse all nodes multiple times.
You mentioned earlier that you need to calculate on nodes that is crossed. Perhaps a centrality algorithm would help you.
All the sessions of the conference are now available online