I am trying to find patterns that include other sub patterns.
I have a graph with Stop and Stoptime nodes and 4 different types of relationships: WALK_TO, GET_ON_THE_BUS, CONTINUE and GET_OFF_THE_BUS. WALK_TOhas distance and speed properties. Other relationships have time properties that I use to calculate the shortest path in time instead of the length of the path.
xStop is a physical entity: a bus stop or a train station. xStoptime has the route info, arrival and departure time of the vehicle to the related stop.
I am trying to find paths from a departure point to a destination point. I split the path into a couple patterns;
start=(dep:xStop {name:'Departure'})-[:WALK_TO]->(:xStop)-[:GET_ON_THE_BUS]->(s:xStoptime)
end = (dest:xStop {name:'Destination'})<-[:WALK_TO]-(:xStop)<-[:GET_OFF_THE_BUS]-(e:xStoptime)
This gives me the ability to filter the relationships of both the start and end legs of the trip.
Now, the middle of trip can be a direct or an indirect trip. If it is a direct trip then:
direct=(:xStoptime)-[:CONTINUE*]->(:xStoptime)
Problem is with the indirect trips: the ones you have to make a transfer to another vehicle. I have 2 different transfer patterns:
t1=(:xStoptime)-[:GET_OFF_THE_BUS]->(a:xStop)-[:WALK_TO]->(b:xStop)-[:Dp]->(:xStoptime)
t2=(c:xStoptime)-[:GET_OFF_THE_BUS]->(:xStop)-[:GET_ON_THE_BUS]->(d:xStoptime) where not c.name=d.name
I want to find paths m
m=(s)-[*]->(e)
where m follows the pattern: direct, zero or more transfers with t1 or t2 , direct.
The reason that I am not using Cypher's shortest path is all relationships have properties on them and I want to calculate multiple costs based on those properties.
Any one can help? How do I write the Cypher query for this?
D,A,RandDprelationships? This question is very hard to follow otherwise. You should probably also change the names of those relationship types (at least when posing this question), so that the patterns can be easier to understand. - cybersam