SlideShare a Scribd company logo
1 of 5
Download to read offline
A Link-State Routing Algorithm

Dijkstra’s algorithm            Notation:
❒ net topology, link costs      ❒ c(x,y): link cost from node
  known to all nodes                x to y; = ∞ if not direct
   ❍ accomplished via “link         neighbors
      state broadcast”
                                ❒   D(v): current value of cost
   ❍ all nodes have same info       of path from source to
❒ computes least cost paths         dest. v
  from one node (‘source”) to
                                ❒   p(v): predecessor node
  all other nodes
                                    along path from source to v
   ❍ gives forwarding table
      for that node             ❒   N': set of nodes whose
                                    least cost path definitively
❒ iterative: after k
                                    known
  iterations, know least cost
  path to k dest.’s
                                                     Network Layer 4-75
Dijsktra’s Algorithm
  1 Initialization:
  2 N' = {u}
  3 for all nodes v
  4    if v adjacent to u
  5        then D(v) = c(u,v)
  6    else D(v) = ∞
  7
  8 Loop
  9 find w not in N' such that D(w) is a minimum
  10 add w to N'
  11 update D(v) for all v adjacent to w and not in N' :
  12      D(v) = min( D(v), D(w) + c(w,v) )
  13 /* new cost to v is either old cost to v or known
  14 shortest path cost to w plus cost from w to v */
  15 until all nodes in N'

                                                     Network Layer 4-76
Dijkstra’s algorithm: example
Step        N'   D(v),p(v) D(w),p(w)             D(x),p(x)   D(y),p(y)   D(z),p(z)
   0         u         2,u       5,u                   1,u          ∞           ∞
   1       ux          2,u       4,x                               2,x          ∞
   2      uxy          2,u       3,y                                          4,y
   3     uxyv                    3,y                                          4,y
   4    uxyvw                                                                 4,y
   5   uxyvwz

                             5

                             v   3       w
                         2                   5
                 u           2           1        z
                                     3
                     1                       2
                             x   1
                                         y

                                                                 Network Layer 4-77
Dijkstra’s algorithm: example (2)
Resulting shortest-path tree from u:


                             v     w
                  u                    z
                             x     y

Resulting forwarding table in u:
    destination       link
              v       (u,v)
              x       (u,x)
              y       (u,x)
              w       (u,x)
              z       (u,x)
                                           Network Layer 4-78
Dijkstra’s algorithm, discussion
    Algorithm complexity: n nodes
    ❒ each iteration: need to check all nodes, w, not in N
    ❒ n(n+1)/2 comparisons: O(n2)
    ❒ more efficient implementations possible: O(nlogn)
    Oscillations possible:
    ❒ e.g., link cost = amount of carried traffic


        1   A                      A                      A                  A
                  1+e     2+e             0        0            2+e    2+e         0
    D       0 0       B   D                   B   D               B    D 1+e 1 B
                                  1+e 1                   0 0
        0         e           0           0           1         1+e     0     e
1
            C                      C                      C                C
                      1
            e
                          … recompute             … recompute         … recompute
        initially
                             routing
                                                                      Network Layer 4-79

More Related Content

What's hot

Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
Linawati Adiman
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
Ahmed Haider
 

What's hot (20)

Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Dijksatra
DijksatraDijksatra
Dijksatra
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approach
 
Dijkstra
DijkstraDijkstra
Dijkstra
 
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson Algorithm
 
Depth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First SearchDepth First Search, Breadth First Search and Best First Search
Depth First Search, Breadth First Search and Best First Search
 
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
 
Bellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer NetworksBellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer Networks
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
graph.ppt
graph.pptgraph.ppt
graph.ppt
 
Graph Theory Introduction
Graph Theory IntroductionGraph Theory Introduction
Graph Theory Introduction
 
Floyd Warshall Algorithm
Floyd Warshall Algorithm Floyd Warshall Algorithm
Floyd Warshall Algorithm
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Tsp branch and bound
Tsp branch and boundTsp branch and bound
Tsp branch and bound
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 

Viewers also liked

All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
are you
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
Lewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional PolicyLewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional Policy
plan4all
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
Kumar
 

Viewers also liked (18)

Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
 
Application of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planningApplication of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planning
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
 
Walking ...
Walking ...Walking ...
Walking ...
 
Lewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional PolicyLewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional Policy
 
Path cycle part1
Path cycle part1Path cycle part1
Path cycle part1
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
 
Bellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathBellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest Path
 
Dijkstra's Algorithm - Colleen Young
Dijkstra's Algorithm  - Colleen YoungDijkstra's Algorithm  - Colleen Young
Dijkstra's Algorithm - Colleen Young
 
The Floyd–Warshall algorithm
The Floyd–Warshall algorithmThe Floyd–Warshall algorithm
The Floyd–Warshall algorithm
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithm
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
 
Interactive subway map
Interactive subway mapInteractive subway map
Interactive subway map
 

Similar to Dijkstra's Algorithm

08-routing-1-slides.pdf
08-routing-1-slides.pdf08-routing-1-slides.pdf
08-routing-1-slides.pdf
AdhiRizal2
 
Linear conformal mapping
Linear conformal mappingLinear conformal mapping
Linear conformal mapping
Tarun Gehlot
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
HJ DS
 
Convolution Neural Networks
Convolution Neural NetworksConvolution Neural Networks
Convolution Neural Networks
AhmedMahany
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineering
mloeb825
 

Similar to Dijkstra's Algorithm (20)

P5 - Routing Protocols
P5 - Routing ProtocolsP5 - Routing Protocols
P5 - Routing Protocols
 
5.2_video_slides.pptx
5.2_video_slides.pptx5.2_video_slides.pptx
5.2_video_slides.pptx
 
Routing Algorithm
Routing AlgorithmRouting Algorithm
Routing Algorithm
 
08-routing-1-slides.pdf
08-routing-1-slides.pdf08-routing-1-slides.pdf
08-routing-1-slides.pdf
 
P2P Supernodes
P2P SupernodesP2P Supernodes
P2P Supernodes
 
04 greedyalgorithmsii
04 greedyalgorithmsii04 greedyalgorithmsii
04 greedyalgorithmsii
 
From RNN to neural networks for cyclic undirected graphs
From RNN to neural networks for cyclic undirected graphsFrom RNN to neural networks for cyclic undirected graphs
From RNN to neural networks for cyclic undirected graphs
 
Link Prediction in the Real World
Link Prediction in the Real WorldLink Prediction in the Real World
Link Prediction in the Real World
 
DIJKSTRA_123.pptx
DIJKSTRA_123.pptxDIJKSTRA_123.pptx
DIJKSTRA_123.pptx
 
Linear conformal mapping
Linear conformal mappingLinear conformal mapping
Linear conformal mapping
 
Module 3- transport_layer .pptx
Module 3- transport_layer           .pptxModule 3- transport_layer           .pptx
Module 3- transport_layer .pptx
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Cnetwork
CnetworkCnetwork
Cnetwork
 
Lecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.pptLecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.ppt
 
Convolution Neural Networks
Convolution Neural NetworksConvolution Neural Networks
Convolution Neural Networks
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineering
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Deepwalk vs Node2vec
Deepwalk vs Node2vecDeepwalk vs Node2vec
Deepwalk vs Node2vec
 
Bellmanford
BellmanfordBellmanford
Bellmanford
 

Dijkstra's Algorithm

  • 1. A Link-State Routing Algorithm Dijkstra’s algorithm Notation: ❒ net topology, link costs ❒ c(x,y): link cost from node known to all nodes x to y; = ∞ if not direct ❍ accomplished via “link neighbors state broadcast” ❒ D(v): current value of cost ❍ all nodes have same info of path from source to ❒ computes least cost paths dest. v from one node (‘source”) to ❒ p(v): predecessor node all other nodes along path from source to v ❍ gives forwarding table for that node ❒ N': set of nodes whose least cost path definitively ❒ iterative: after k known iterations, know least cost path to k dest.’s Network Layer 4-75
  • 2. Dijsktra’s Algorithm 1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞ 7 8 Loop 9 find w not in N' such that D(w) is a minimum 10 add w to N' 11 update D(v) for all v adjacent to w and not in N' : 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N' Network Layer 4-76
  • 3. Dijkstra’s algorithm: example Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z) 0 u 2,u 5,u 1,u ∞ ∞ 1 ux 2,u 4,x 2,x ∞ 2 uxy 2,u 3,y 4,y 3 uxyv 3,y 4,y 4 uxyvw 4,y 5 uxyvwz 5 v 3 w 2 5 u 2 1 z 3 1 2 x 1 y Network Layer 4-77
  • 4. Dijkstra’s algorithm: example (2) Resulting shortest-path tree from u: v w u z x y Resulting forwarding table in u: destination link v (u,v) x (u,x) y (u,x) w (u,x) z (u,x) Network Layer 4-78
  • 5. Dijkstra’s algorithm, discussion Algorithm complexity: n nodes ❒ each iteration: need to check all nodes, w, not in N ❒ n(n+1)/2 comparisons: O(n2) ❒ more efficient implementations possible: O(nlogn) Oscillations possible: ❒ e.g., link cost = amount of carried traffic 1 A A A A 1+e 2+e 0 0 2+e 2+e 0 D 0 0 B D B D B D 1+e 1 B 1+e 1 0 0 0 e 0 0 1 1+e 0 e 1 C C C C 1 e … recompute … recompute … recompute initially routing Network Layer 4-79