atom

Dijkstras Algorithm

Dijkstra’s Algorithm (Link State)

💡 The Core Idea

Dijkstra’s algorithm calculates the least-cost path from a source node to all other nodes in a network by iteratively adding the closest unvisited node to a set of confirmed nodes (NN').

🧠 Mechanism

  1. Initialization: The source node knows the cost to its immediate neighbors. All non-neighbors are set to infinity.
  2. Iteration:
    • Select the node (ww) outside of set NN' with the lowest cost.
    • Add ww to NN'.
    • Update neighbors of ww: Is it cheaper to go through ww to get to neighbor vv?
      • D(v)=min(D(v),D(w)+c(w,v))D(v) = min(D(v), D(w) + c(w,v)).
  3. Completion: Algorithm stops when all nodes are in NN' (requires nn iterations).

Complexity

The computational complexity is O(n2)O(n^2), where nn is the number of nodes.

🔗 Connections