DSAVisualiseData Structures & Algorithms Studio
Paths & Grids Hard

Multi-Source Dijkstra (Evacuation)

A multi-source Dijkstra search expands outward from all exits and records the next venue toward the closest one.

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(V²)
AverageO(V²)
WorstO(V²)
SpaceO(V)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

For every venue, return the next vertex on a least-weight route to any exit; exits use -1 and unreachable venues use -2.

  • Starting from each venue separately.
  • Confusing the next hop with the previous hop.
  • Losing the -1 exit and -2 unreachable sentinels.

Algorithm code

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

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1