DSAVisualiseData Structures & Algorithms Studio
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 JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

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.

Live snapshot

Current operation

Trace state
Ready 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

Java
Trains.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1