Skip to content
LaTeX (KaTeX) templates

Math — Dijkstra's Algorithm

Shortest paths from a source node.

Template previewLaTeX (KaTeX)
d[v]=min⁡(d[v], d[u]+w(u,v))d[v] = \min(d[v],\ d[u] + w(u,v))greedy: pick the nearest unvisited\text{greedy: pick the nearest unvisited}requires non-negative weights\text{requires non-negative weights}O((V+E)log⁡V) with a heapO((V + E)\log V)\ \text{with a heap}

What this template contains

Equations
4
Source
4 lines

Make it your own.

d[v] = \min(d[v],\ d[u] + w(u,v))

\text{greedy: pick the nearest unvisited}

\text{requires non-negative weights}

O((V + E)\log V)\ \text{with a heap}