Fiveable

๐ŸŽ›๏ธOptimization of Systems Unit 7 Review

QR code for Optimization of Systems practice questions

7.3 Shortest path algorithms

๐ŸŽ›๏ธOptimization of Systems
Unit 7 Review

7.3 Shortest path algorithms

Written by the Fiveable Content Team โ€ข Last updated September 2025
Written by the Fiveable Content Team โ€ข Last updated September 2025
๐ŸŽ›๏ธOptimization of Systems
Unit & Topic Study Guides

Graph theory and shortest path algorithms are crucial in optimization. These tools help solve real-world problems by finding the most efficient routes in networks. From GPS navigation to currency exchange, these algorithms have wide-ranging applications.

Dijkstra's algorithm excels with non-negative weights, using a greedy approach. Bellman-Ford, while slower, handles negative weights and detects negative cycles. Understanding their strengths and limitations is key to choosing the right tool for specific network optimization challenges.

Graph Theory and Shortest Path Algorithms

Characteristics of shortest path problems

  • Problem formulation requires defining source and destination nodes representing network as a graph with nodes (cities) and edges (roads) assigning weights to edges based on distance, time, or cost
  • Key characteristics include directed or undirected graphs weighted edges single-source or all-pairs shortest paths
  • Constraints involve non-negative edge weights for some algorithms absence of negative cycles (loops that decrease total path weight)
  • Optimization objective aims to minimize total path weight finding most efficient route

Application of Dijkstra's algorithm

  • Algorithm overview uses greedy approach iteratively selecting nearest unvisited node
  • Data structures employ priority queue for efficient node selection distance array stores tentative distances previous node array for path reconstruction
  • Algorithm steps:
    1. Initialize distances and previous nodes
    2. Set source node distance to zero
    3. While unvisited nodes exist select node with minimum tentative distance update distances of adjacent nodes mark current node as visited
  • Time complexity $O((V + E) \log V)$ with binary heap space complexity $O(V)$
  • Limitations prevent handling negative edge weights

Bellman-Ford for negative weights

  • Algorithm overview utilizes dynamic programming approach performs edge relaxation V-1 times
  • Data structures include distance array to store tentative distances previous node array for path reconstruction
  • Algorithm steps:
    1. Initialize distances and previous nodes
    2. Repeat V-1 times for each edge (u, v) with weight w if distance[v] > distance[u] + w update distance[v]
    3. Check for negative cycles
  • Time complexity $O(VE)$ space complexity $O(V)$
  • Advantages include handling negative edge weights detecting negative cycles

Comparison and Applications

Dijkstra's vs Bellman-Ford algorithms

  • Performance: Dijkstra's faster for non-negative weights Bellman-Ford slower but handles negative weights
  • Completeness: Dijkstra's incomplete for negative weights Bellman-Ford complete for all cases without negative cycles
  • Negative cycle detection: Dijkstra's cannot detect Bellman-Ford can detect and report
  • Parallelization: Dijkstra's difficult to parallelize Bellman-Ford easier to parallelize
  • Applications:
    • Dijkstra's: GPS navigation systems (Google Maps) network routing protocols (OSPF) transportation planning (optimizing delivery routes)
    • Bellman-Ford: Currency exchange arbitrage detection distributed systems with potential negative costs Quality of Service routing (minimizing packet loss)