I am trying to run these two cypher queries and I am not understanding the difference between them. The purpose here is to find multiple paths between given two nodes such that the sum of transit_time in that path is in ascending order.
Q1 :
MATCH p =(:`ml` { placeId: 960 })-[:ETA*0..10]->(:`ml` { placeId: 814 })
return p, p as allshortestPaths,
REDUCE(time=0, r in relationships(p) | time+r.transit_time) AS totalTime
ORDER BY totalTime ASC
Q2 :
MATCH (from:`ml` { placeId: 960}), (to: `ml` {placeId: 814}) ,
paths = allShortestPaths((from)-[:ETA*]->(to))
WITH REDUCE(time = 0, rel in rels(paths) | time + rel.transit_time)
AS totalTime, paths
RETURN (totalTime)
ORDER BY totalTime ASC
In this I get the best result from Q1
Also these operations take very long time.
Any other better way to do that may be using graph algorithms? I think it is possible to do this using Dijkstra algorithm any help about how to specify cost_parameter there and how to use will be great.
I am using py2neo and neo4j.
Neo4j has an integrated tool to explain queries, in fact it's not explaining but profiling.
You can also find here some documentation about execution plan, to explain each operation.