Skip to content

Instantly share code, notes, and snippets.

@petehughes
Created July 12, 2022 18:39
Show Gist options
  • Save petehughes/27caa3285cffb52fdc75a179ba83737c to your computer and use it in GitHub Desktop.
Save petehughes/27caa3285cffb52fdc75a179ba83737c to your computer and use it in GitHub Desktop.
%%cypher
MATCH path = shortestPath( (:Station {name:'Watford'})-[:LEG*]-(:Station {name: 'Liverpool Street'}) )
with [n in nodes(path)|n.name] as Stations, [n in relationships(path)|n.line] as AlLines, reduce(time = 0, n in relationships(path) | time + n.time) as time
where time > 0
with [i in range(0, size(AlLines)-1)
WHERE i=0 OR AlLines[i] <> AlLines[i-1] | AlLines[i] ] AS Lines, AlLines, Stations, time
RETURN Lines, Stations, time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment