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

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 dijkstraRoshan Tailor
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithmRuchika Sinha
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmTamzida_Azad
 
Bellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer NetworksBellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer NetworksSimranJain63
 
Depth First Search ( DFS )
Depth First Search ( DFS )Depth First Search ( DFS )
Depth First Search ( DFS )Sazzad Hossain
 
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsrLinawati Adiman
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first searchHossain Md Shakhawat
 
Graph traversal-BFS & DFS
Graph traversal-BFS & DFSGraph traversal-BFS & DFS
Graph traversal-BFS & DFSRajandeep Gill
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approachAkash Sethiya
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - GraphMadhu Bala
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]DEEPIKA T
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structuresMohd Arif
 

What's hot (20)

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
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Bellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer NetworksBellman Ford Routing Algorithm-Computer Networks
Bellman Ford Routing Algorithm-Computer Networks
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
Graph data structure and algorithms
Graph data structure and algorithmsGraph data structure and algorithms
Graph data structure and algorithms
 
Depth First Search ( DFS )
Depth First Search ( DFS )Depth First Search ( DFS )
Depth First Search ( DFS )
 
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
 
Dfs
DfsDfs
Dfs
 
PRIM'S ALGORITHM
PRIM'S ALGORITHMPRIM'S ALGORITHM
PRIM'S ALGORITHM
 
Breadth first search
Breadth first searchBreadth first search
Breadth first search
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
Graph traversal-BFS & DFS
Graph traversal-BFS & DFSGraph traversal-BFS & DFS
Graph traversal-BFS & DFS
 
Dijkstra
DijkstraDijkstra
Dijkstra
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approach
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
 

Viewers also liked

Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraOnggo Wiryawan
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Anshul gour
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithmSrikrishnan Suresh
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithmare you
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problemIfra Ilyas
 
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 planningDarling Jemima
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Traian Rebedea
 
Walking ...
Walking ...Walking ...
Walking ...vlastos
 
Lewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional PolicyLewis Dijkstra, DG Regional Policy
Lewis Dijkstra, DG Regional Policyplan4all
 
Path cycle part1
Path cycle part1Path cycle part1
Path cycle part1guestb63941
 
Bellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathBellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathSharmilaChidaravalli
 
Dijkstra's Algorithm - Colleen Young
Dijkstra's Algorithm  - Colleen YoungDijkstra's Algorithm  - Colleen Young
Dijkstra's Algorithm - Colleen YoungColleen Young
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithmPulkit Goel
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16Kumar
 

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
 
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)
 
Dijksatra
DijksatraDijksatra
Dijksatra
 
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.pdfAdhiRizal2
 
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 graphstuxette
 
Link Prediction in the Real World
Link Prediction in the Real WorldLink Prediction in the Real World
Link Prediction in the Real WorldBalaji Ganesan
 
Linear conformal mapping
Linear conformal mappingLinear conformal mapping
Linear conformal mappingTarun Gehlot
 
Module 3- transport_layer .pptx
Module 3- transport_layer           .pptxModule 3- transport_layer           .pptx
Module 3- transport_layer .pptxhariprasad279825
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2MuradAmn
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slidesHJ DS
 
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.pptWahyuAde4
 
Convolution Neural Networks
Convolution Neural NetworksConvolution Neural Networks
Convolution Neural NetworksAhmedMahany
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineeringmloeb825
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsSigSegVSquad
 

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