A complex use case of graph!

To facilitate better answering of questions, if you have a question, please fill in the following info. Otherwise, please delete the template.

What I want to do

This is the schema

type Station {
node: int @index(int) @upsert .
edge: [uid] .

And here is the sample data

_:st1 <dgraph.type> "Station" .
_:st2 <dgraph.type> "Station" .
_:st3 <dgraph.type> "Station" .
_:st4 <dgraph.type> "Station" .
_:st5 <dgraph.type> "Station" .
_:st6 <dgraph.type> "Station" .

_:st1 <node> "1" .
_:st2 <node> "2" .
_:st3 <node> "3" .
_:st4 <node> "4" .
_:st5 <node> "5" .
_:st6 <node> "6" .

_:st2 <edge> _:st1 (start=2022-05-01T10:10:10, end=2022-05-01T10:20:10, cost=12) .
_:st3 <edge> _:st1 (start=2022-05-01T10:40:10, end=2022-05-01T10:50:10, cost=13) .
_:st1 <edge> _:st4 (start=2022-05-01T10:10:10, end=2022-05-01T10:20:10, cost=10) .
_:st1 <edge> _:st5 (start=2022-05-01T10:30:10, end=2022-05-01T10:40:10, cost=12) .
_:st1 <edge> _:st6 (start=2022-05-01T10:10:10, end=2022-05-01T10:40:10, cost=13) .
_:st5 <edge> _:st6 (start=2022-05-01T10:50:10, end=2022-05-01T10:55:10, cost=13) .

I want to get from station 2 to station 6.
So, there are 2 paths. 2->1->6 and 2->1->5->6.
There’s a problem.
In the first case when I go from 2 to 1 the time is 2022-05-01T10:20:10 and the 1->5 race has already been gone, so I should receive the 2nd option as the available path for my “shortest path” query.

So, how do I go about implementing it?

you gotta do that distance stuff, this is totally possible with DQL. but i am not a math genius, but there is a great tutorial

maybe this here helps you

there he also explains distance functions