I have a graph with the following structure:
(r:Region)-[:CONTAINS]-(s:Station)-[:IS_AT]-(t:TrackLocation)-[:IS_NEXT_TO]-(t:TrackLocation)
I want to find the shortest path between two Stations, using only track locations. My current query is:
match (s1:Station) where s1.crs = 'ADR' match (s2:Station) where s2.crs = 'NRW' match p=shortestPath((s1)-[*1..1000]-(s2)) WHERE ALL (n IN nodes(p) WHERE NOT n:Region) return nodes(p).
The problem is, a station can be at multiple TrackLocations; and sometimes the shortest path can go via an intermediate Station node if it thinks this is quicker than sticking to TrackLocations for the intermediate nodes. If I change the filter to WHERE NOT n:Region AND NOT n:Station, then of course it won't work because the start and end nodes are stations.
Is there any way to adjust this query to do (Station)-> via track locations only ->(Station)?