Analog and digital C - Dijkstra's Shortest Path algorithm, Study notes of Digital & Analog Electronics

Detailed informtion about Dijkstra's Shortest Path algorithm, Introduction, Algorithm, Dijsktra’s Pseudo code, Dijkstra’s algorithm: example, initial node.

Typology: Study notes

2010/2011

Uploaded on 09/02/2011

hamit1990
hamit1990 🇮🇳

4.3

(76)

95 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dijkstra's Shortest Path
algorithm
pf3
pf4
pf5

Partial preview of the text

Download Analog and digital C - Dijkstra's Shortest Path algorithm and more Study notes Digital & Analog Electronics in PDF only on Docsity!

Dijkstra's Shortest Path

algorithm

Introduction

• For a given source vertex (node) in the graph,

the algorithm finds the path with lowest cost (i.e.

the shortest path) between that vertex and every

other vertex.

• It can also be used for finding costs of shortest

paths from a single vertex to a single destination

vertex by stopping the algorithm once the

shortest path to the destination vertex has been

determined.

Example

Dijsktra’s Pseudo code

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'

Dijkstra’s algorithm: example

Step 0 1 2 3 4 5

N'

B

BA

BAC

BACD

BACDE

BACDEF

D(A),p(A) 3,B D(C),p(C) 5,B 4,A D(D),p(D) D(E),p(E) ∞ ∞ D(F),p(F) ∞ ∞ ∞ 15,D 9,E ∞ ∞ 6,C 8,C 8,C