Dijkstra's Algorithm

Find weighted shortest paths

Dijkstra computes shortest paths considering edge weights - optimal for finding lowest-cost routes.

What It Computes

Minimum-weight path from source to all reachable nodes.

When to Use It

  • Weighted networks: Edges have costs/distances/times
  • Route optimization: Find cheapest/fastest path
  • Resource allocation: Minimize cost

Parameters

ParameterTypeDescription
sourcenode/strStarting node
weight_propstrEdge weight property
targetnode/strOptional destination

Performance

Time: O((V + E) log V)
Scales to: 10M edges

Example

Use Cases

Supply Chain

Find lowest-cost shipping routes

Network Routing

Optimize packet routing by latency

Resource Planning

Minimize cost/time to reach objectives

Dijkstra vs BFS

BFS (unweighted): Use when all edges equal
Dijkstra (weighted): Use when edges have costs

See Also