This is my graph schema (little part):
BusStation
is class which extends V
(Vertex).
Every BusStation
element has stationId
property with some value (1,2,3,4,5...).
Bus
is class which extends E
(Edge).
Every Bus
element has three properties:
busId
: Id of bus between two station (Long)departure
: time when bus went from station (Datetime)arrival
: time when bus came on next station (Datetime)
I want to find $path
from BusStation
with stationId = 1
to BusStation
with stationId = 5
.
When I execute this query through editor/Java code:
SELECT $path as path FROM (TRAVERSE outE(Bus), inV(BusStation) FROM select * from BusStation where stationId = 1 strategy BREADTH_FIRST) WHERE @rid == #17:3509
I will get shortest path, but I have some conditions which I must follow:
First I want to be on same bus as longer is posible. This means that if I get on
stationId = 1
Bus
withbusId = 1
onstationId = 2
I want also getbusId = 1
, onstationId = 3
so on, and onstationId = 4
because I don't havebusId = 1
I will pick one of possible ability.Second is filter on arrival time of one bus and departure bus to another bus. I must watch out that if some bus arrive on station in 09:00, I must pick from that BusStation buses which have departure time after that arrive time (09:00).
Do you have some idea how thru query I can filter this conditions?