I am newbie to gremlin. I have a graph with airports as nodes and flights as edges with arrival time and departure time as edge properties. Now I am trying to use tinkerpop 3.1 to get the list of connections with 1 layovers, 2 layovers, 3 layovers given a origin airport, destination airport and departure time . I got it to work for 1 layover using below query. I am having tough time trying to generalize this query to find n connections using repeat and match. Any help is appreciated.
Sample graph script
graph = TinkerFactory.createModern()
g = graph.traversal()
g.addV('airport').property('name','PDX').as('PDX').
addV('airport').property('name','JFK').as('JFK').
addV('airport').property('name','PHX').as('PHX').
addV('airport').property('name','ORD').as('ORD').
addV('airport').property('name','IAD').as('IAD').
addE('flight').property('depTime',9).property('arrTime',10).from('PDX').to('JFK').
addE('flight').property('depTime',10).property('arrTime',11).from('PDX').to('PHX').
addE('flight').property('depTime',12).property('arrTime',13).from('PDX').to('ORD').
addE('flight').property('depTime',13).property('arrTime',14).from('PDX').to('IAD').
addE('flight').property('depTime',11).property('arrTime',14).from('JFK').to('IAD').
addE('flight').property('depTime',10).property('arrTime',12).from('PHX').to('IAD').
addE('flight').property('depTime',14).property('arrTime',15).from('ORD').to('IAD').iterate()
Gremlin query
g.V().has("airport","name","PDX").outE().has("depTime",gt(6)).
match(
__.as('e1').values('arrTime').as('e1Arr'),
__.as('e1').outV().as('v1'),
__.as('e1').inV().as('v2'),
__.as('v2').outE().as('e2'),
__.as('e2').values('depTime').as('e2Dep')).
where('e2Dep',gt('e1Arr')).select('e2').inV().as("v3").has("airport","name","IAD").
select("v1","e1","v2","e2","v3").by("name").by(valueMap()).by("name").by(valueMap()).by("name");