I'm working on a road network analysis using Neo4j and GDS, and I need help with an efficient way to compute shortest paths between all "Location" (label) nodes that belong to a specific Louvain community.
What I did :
Graph projection:
CALL gds.graph.project(
'locGraph1',
['Location', 'OGLoc'],
{
CONNECTED_BY: {
type: 'CONNECTED_BY',
orientation: 'UNDIRECTED',
properties: 'Length'
}
}
)
MATCH (source:Location), (target:Location)
WHERE id(source) < id(target)
CALL gds.shortestPath.dijkstra.stream('locGraph1', {
sourceNode: id(source),
targetNode: id(target),
relationshipWeightProperty: 'Length'
})
YIELD totalCost
RETURN source.Node3ID AS from, target.Node3ID AS to, totalCost AS cost
…but this crashes with:
Neo.TransientError.General.MemoryPoolOutOfMemoryError
Even though I only want to do it for a single community, I have over 3,400 nodes which creates ~5.8 million pairs.
-
Is there a memory-efficient way to compute all-pairs Dijkstra paths within a community using GDS?
-
Can I use gds.beta.shortestPath.dijkstra.stream with sourceNodeIds in GDS 2.x? If not, what’s the recommended workaround?
-
Should I switch to a different algorithm (like allShortestPaths or allShortestPaths.deltaStepping)?
-
Would you recommend writing a custom loop outside GDS (via APOC or Python) — or is there a better built-in solution?
Total Nodes in Location are approx. -9K , but I tested on a small batch of 3K