DSAVisualiseData Structures & Algorithms Studio
Paths & Grids Hard

Computer Virus Propagation

A directed network spreads a virus as servers finish incubating; Dijkstra's priority queue determines the earliest infectious time for every reachable server.

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 + E log V)
AverageO(V + E log V)
WorstO(V + E log V)
SpaceO(V + E)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Return each reachable server's earliest infectious time. A server starts its incubation when an infectious neighbor reaches it; the start server begins at time zero.

  • Recording a server's arrival time without adding its incubation delay.
  • Treating directed connections as two-way links.
  • Processing every duplicate queue candidate instead of skipping already-infected servers.
  • Assuming Dijkstra's earliest-time guarantee holds for negative incubation delays.

Algorithm code

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

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Visited 0 · Writes 0