3

This is my graph schema (little part):

enter image description here

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 with busId = 1 on stationId = 2 I want also get busId = 1, on stationId = 3 so on, and on stationId = 4 because I don't have busId = 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?

Juraj Ćutić
  • 206
  • 2
  • 10

0 Answers0