RK DSA Studio

Dijkstra

Find shortest paths from a source with nonnegative edge weights by settling the nearest unsettled vertex and relaxing its outgoing edges.

Remember: Nonnegative weights; settle nearest; relax neighbors.

Example: A→B costs 4; A→C→B costs 1+2 → distance to B is 3.

Time: O(V² + E). Auxiliary space: O(V).

Formula: dist[v] = min(dist[v], dist[u] + weight(u,v))

Up to 8 unique integer vertex labels and 16 edges. Edges: from,to,weight; weights must be integers from 0 to 999. Uses a linear minimum scan, not a heap. Directed graph. Explore only the source component. Graph storage O(V + E) is excluded from auxiliary space.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.