I am very new to Neo4j. Could someone kindly explain to me (step-by-step please) how I could implement the Dijkstra's algorithm to find the shortest path between two nodes? Is it possible to simply do it using Cypher?
I already tried the shortestPath algorithm, but it is very slow:
MATCH (from: Location {LocationName:"x"}), (to: Location {LocationName:"y"}) , path = (from)-[:CONNECTED_TO*1..5]->(to)
RETURN path AS shortestPath,
reduce(distance = 0, r in relationships(path)| distance+toInt(r.Distance))
AS totalDistance
ORDER BY totalDistance ASC
LIMIT 1
my nodes are: Location with properties LocationID and LocationName my relationships are: CONNECTED_TO with property Distance
I have more than 6000 relationships
please note in the code above that I have limited to 1..5 when I do not define this limit, the query does not give any results (keeps on executing)
thanks