Paths & Grids Hard
Time-Expanded Graph (Train Routing)
Train connections form a time-expanded graph: a station can use any departure at or after its earliest arrival.
Trace input
Bounded JSONEdit the lesson input, then build a deterministic source-linked trace.
Source scenarios
Complexity
BestO(T log T + T²)
AverageO(T log T + T²)
WorstO(T log T + T²)
SpaceO(T + S)
Array state
Follow the active comparisons and writes.
Current operation
Trace stateReady to explore
Source behavior & common mistakes
Compute the earliest arrival at every reachable station, keeping each listed train departure and arrival time.
- Treating station names as the only graph vertices.
- Taking a train that departs before arrival.
- Requiring a traveler to wait for only one chosen departure.
Algorithm code
JavaTrains.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1