Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query proposal: RouteLength #110

Open
szarnyasg opened this issue Oct 3, 2017 · 0 comments
Open

Query proposal: RouteLength #110

szarnyasg opened this issue Oct 3, 2017 · 0 comments

Comments

@szarnyasg
Copy link
Member

szarnyasg commented Oct 3, 2017

A route's total length must be smaller than X (e.g. 100.000 m).

Given our current model, this is quite difficult to calculate.

MATCH
  (route:Route)-[:follows]->(swP1:SwitchPosition)-[:target]->(sw1:Switch),
        (route)-[:follows]->(swP2:SwitchPosition)-[:target]->(sw2:Switch)
WHERE sw1.id < sw2.id
MATCH p=(sw1)-[:connectsTo*]-(sw2)
WITH route, nodes(p) AS tes
// only the start and the end of the path are switches
WHERE size(filter(te IN tes WHERE NOT (te:Segment))) = 2
UNWIND tes AS te
RETURN route, sum(te.length) AS length

It seems it's quicker using shortestPath:

MATCH
  (route:Route)-[:follows]->(swP1:SwitchPosition)-[:target]->(sw1:Switch),
        (route)-[:follows]->(swP2:SwitchPosition)-[:target]->(sw2:Switch)
WHERE sw1.id < sw2.id
MATCH p=shortestPath((sw1)-[:connectsTo*]-(sw2))
WITH route, nodes(p) AS tes
// only the start and the end of the path are switches
WHERE size(filter(te IN tes WHERE NOT (te:Segment))) = 2
UNWIND tes AS te
RETURN route, sum(te.length) AS length

#101

szarnyasg added a commit that referenced this issue Oct 13, 2017
szarnyasg added a commit that referenced this issue Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant