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
| Parameter | Type | Description |
|---|---|---|
source | node/str | Starting node |
weight_prop | str | Edge weight property |
target | node/str | Optional 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
- Single Source Shortest Path - Unweighted (BFS)
- Temporal Reachability