Dijkstra's algorithm
An algorithm that finds the cheapest route between two nodes.
Also written: Dijkstra
Example
Two roads out of Ashford reach Croydon, one directly and one through Barnet.
cypher
MATCH (source:Stop {name: 'Ashford'}), (target:Stop {name: 'Croydon'})
CALL gds.shortestPath.dijkstra.stream('roads', {
sourceNode: source,
targetNode: target,
relationshipWeightProperty: 'cost'
})
YIELD totalCost, path
RETURN path, totalCostThe route through Barnet costs 5. The road straight to Croydon costs 10, so Dijkstra returns the two-road route instead.
Lessons that use this term
The lesson and course links below open in a new tab.
No published lesson uses this term yet.