Last active
May 19, 2019 13:09
-
-
Save vladbatushkov/20717f864ac0a855cd03cd54b3e21683 to your computer and use it in GitHub Desktop.
Museums to visit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (from:Museum) | |
MATCH (to:Museum) | |
WHERE id(from) < id(to) | |
CALL algo.kShortestPaths.stream(from, to, 1, 'distanceKm') YIELD index, nodeIds, costs | |
WITH [node in algo.getNodesById(nodeIds) | node.name] AS museums, | |
duration({ minutes: reduce(acc = 0.0, cost in costs | acc + (cost / 4 * 60)) }) AS walkDuration, | |
duration({ minutes: reduce(acc = 20.0, cost in costs | acc + 20) }) AS visitDuration | |
WITH museums, walkDuration, visitDuration, duration({ minutes: walkDuration.minutes + visitDuration.minutes }) as totalDuration | |
WHERE totalDuration.minutes <= 300 | |
RETURN DISTINCT museums, size(museums) as totalMuseums, walkDuration.hours + "h " + walkDuration.minutesOfHour + "m" as walkDuration, visitDuration.hours + "h " + visitDuration.minutesOfHour + "m" as visitDuration, totalDuration.hours + "h " + totalDuration.minutesOfHour + "m" as totalDuration | |
ORDER BY totalMuseums DESC, walkDuration ASC | |
LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment