It's 2009 and you are staying in Oak City for the summer. Because of its history leading to people-centric urban planning, it has a free, well-planned, and timely public transit system, unlike the MTA. Since smartphones aren't widespread yet, you have a map with a lot to work with. The map is a connected graph and there are directed edges (u, v) between the stations on the map, and each edge e=(u,v) has the following data:
**length(e):** the time, in minutes, it takes to travel from u to v
**first(e)>= 0** the first train of the day that passes through u to v
**freq(e) > 0** how frequently the train comes from u to v
So the train passes through that a station at first(e), first(e) + freq(e), first(e) + 2freq(e), and so on... Transfers are also super efficient because the platforms are well designed. So you can assume that as soon as you arrive at somewhere to get off, if your transfer train arrives at the same time you can catch it.
With your copy of the map, you store the data in files and want to make an API that'll tell you the shortest time it takes to get from a station S to station T at a certain starting time. Since you are the only one using the API, you just care about getting places from a single starting station. For the API, you'll design an algorithm. You don't care how many transfers you have to make.
Given: starting time X minutes from 5:30am, station S, station T, three adjacency matrices (one for length(e), another for first(e), another for freq(e)). The first(e) adjacency matrix could just contain the first arrival time as number of minutes from 5:30am, so 6:01am would be 31.
Goal: Find the shortest time it would take to get from S to T.
Note: If at Y trains arrive at 5:59a, 6:07a, 6:15a, 6:23a, etc. If I make it to Y at 6:21a I'll have to wait 2 minutes but if I make it at 6:23a I can get on right away.
If you're familiar with math programming, you can model this problem as an integer linear program.
Your objective would be to reach your destination as soon as possible, i.e. to minimize some arrival time $\tau$. Your decision variables will likely be binary, and you'll want constraints which ensure: (i) the first train you take leaves from the starting station, (ii) the last train you take arrives at the destination, and (iii) you can only transfer to a new train if you arrive to the correct station on time.
Don't want to solve the problem for you, since it seems like a homework problem. But for more ideas on how to model the problem and develop a solution algorithm, read about work done on the Vehicle Routing Problem (VRP), and the VRP with time windows. There are good resources online, and Fundamentals of Supply Chain Theory (Snyder and Shen) is a good reference.