Last active
January 5, 2020 14:51
-
-
Save vladbatushkov/4730f93884bca4402264bd3f171d62cb to your computer and use it in GitHub Desktop.
Flights Search Application Path Filtered
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
WITH { a: "Moscow", b: "New York" } as params | |
MATCH (a:Airport { city: params.a }), (b:Airport { city: params.b }) | |
WITH params, AVG(a.location.latitude) as ala, AVG(a.location.longitude) as alo, AVG(b.location.latitude) as bla, AVG(b.location.longitude) as blo | |
WITH params { .*, max: distance(point({ latitude: ala, longitude: alo }), point({ latitude: bla, longitude: blo })) / 1000 * 1.05 } | |
MATCH path = ((a:Airport { city: params.a })-[:FLIES_TO*..3]->(b:Airport { city: params.b })) | |
WHERE apoc.coll.sum([x IN relationships(path) | x.distance ]) <= params.max AND SIZE(apoc.coll.duplicates([ x IN nodes(path) | x.city ])) = 0 | |
RETURN nodes(path) as routes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment