SlideShare a Scribd company logo
DIJKSTRA'S ALGORITHM
By Laksman Veeravagu and Luis Barrera
THE AUTHOR: EDSGER WYBE DIJKSTRA
"Computer Science is no more about computers than
astronomy is about telescopes."
http://www.cs.utexas.edu/~EWD/
EDSGER WYBE DIJKSTRA
- May 11, 1930 – August 6, 2002
- Received the 1972 A. M. Turing Award, widely considered the
most prestigious award in computer science.
- The Schlumberger Centennial Chair of Computer Sciences at
The University of Texas at Austin from 1984 until 2000
- Made a strong case against use of the GOTO statement in
programming languages and helped lead to its deprecation.
- Known for his many essays on programming.
SINGLE-SOURCE SHORTEST PATH PROBLEM
Single-Source Shortest Path Problem - The problem of
finding shortest paths from a source vertex v to all other
vertices in the graph.
DIJKSTRA'S ALGORITHM
Dijkstra's algorithm - is a solution to the single-source
shortest path problem in graph theory.
Works on both directed and undirected graphs. However, all
edges must have nonnegative weights.
Approach: Greedy
Input: Weighted graph G={E,V} and source vertex v∈V, such
that all edge weights are nonnegative
Output: Lengths of shortest paths (or the shortest paths
themselves) from a given source vertex v∈V to all other
vertices
DIJKSTRA'S ALGORITHM - PSEUDOCODE
dist[s] ←0 (distance to source vertex is zero)
for all v ∈ V–{s}
do dist[v] ←∞ (set all other distances to infinity)
S←∅ (S, the set of visited vertices is initially empty)
Q←V (Q, the queue initially contains all vertices)
while Q ≠∅ (while the queue is not empty)
do u ← mindistance(Q,dist) (select the element of Q with the min. distance)
S←S∪{u} (add u to list of visited vertices)
for all v ∈ neighbors[u]
do if dist[v] > dist[u] + w(u, v) (if new shortest path found)
then d[v] ←d[u] + w(u, v) (set new value of shortest path)
(if desired, add traceback code)
return dist
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
DIJKSTRA ANIMATED EXAMPLE
IMPLEMENTATIONS AND RUNNING TIMES
The simplest implementation is to store vertices in an array
or linked list. This will produce a running time of
O(|V|^2 + |E|)
For sparse graphs, or graphs with very few edges and many
nodes, it can be implemented more efficiently storing the
graph in an adjacency list using a binary heap or priority
queue. This will produce a running time of
O((|E|+|V|) log |V|)
DIJKSTRA'S ALGORITHM - WHY IT WORKS
 As with all greedy algorithms, we need to make sure that it
is a correct algorithm (e.g., it always returns the right solution
if it is given correct input).
 A formal proof would take longer than this presentation, but
we can understand how the argument works intuitively.
 If you can’t sleep unless you see a proof, see the second
reference or ask us where you can find it.
 To understand how it works, we’ll go over the previous
example again. However, we need two mathematical
results first:
 Lemma 1: Triangle inequality
If δ(u,v) is the shortest path length between u and v,
δ(u,v) ≤ δ(u,x) + δ(x,v)
 Lemma 2:
The subpath of any shortest path is itself a shortest
path.
 The key is to understand why we can claim that anytime we
put a new vertex in S, we can say that we already know the
shortest path to it.
 Now, back to the example…
DIJKSTRA'S ALGORITHM - WHY IT WORKS
 As mentioned, Dijkstra’s algorithm calculates the
shortest path to every vertex.
 However, it is about as computationally expensive
to calculate the shortest path from vertex u to
every vertex using Dijkstra’s as it is to calculate the
shortest path to some particular vertex v.
 Therefore, anytime we want to know the optimal
path to some other vertex from a determined
origin, we can use Dijkstra’s algorithm.
DIJKSTRA'S ALGORITHM - WHY USE IT?
APPLICATIONS OF DIJKSTRA'S ALGORITHM
- Traffic Information Systems are most prominent use
- Mapping (Map Quest, Google Maps)
- Routing Systems
APPLICATIONS OF DIJKSTRA'S
ALGORITHM
 One particularly relevant this
week: epidemiology
 Prof. Lauren Meyers (Biology
Dept.) uses networks to model the
spread of infectious diseases and
design prevention and response
strategies.
 Vertices represent individuals,
and edges their possible contacts.
It is useful to calculate how a
particular individual is connected
to others.
 Knowing the shortest path
lengths to other individuals can be
a relevant indicator of the
potential of a particular individual
to infect others.
 Dijkstra’s original paper:
E. W. Dijkstra. (1959) A Note on Two Problems in Connection with
Graphs. Numerische Mathematik, 1. 269-271.
 MIT OpenCourseware, 6.046J Introduction to Algorithms.
< http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-
Science/6-046JFall-2005/CourseHome/> Accessed 4/25/09
 Meyers, L.A. (2007) Contact network epidemiology: Bond percolation
applied to infectious disease prediction and control. Bulletin of the
American Mathematical Society 44: 63-86.
 Department of Mathematics, University of Melbourne. Dijkstra’s
Algorithm.
<http://www.ms.unimelb.edu.au/~moshe/620-
261/dijkstra/dijkstra.html > Accessed 4/25/09
REFERENCES

More Related Content

PPTX
Dijkstra's algorithm presentation
PPT
dijkstra algo.ppt
PPT
Dijkstra's algorithm for computer science
PPTX
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
PPTX
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
PPTX
Networks dijkstra's algorithm- pgsr
PPTX
Algo labpresentation a_group
PDF
Dijkstra's Algorithm
Dijkstra's algorithm presentation
dijkstra algo.ppt
Dijkstra's algorithm for computer science
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
Networks dijkstra's algorithm- pgsr
Algo labpresentation a_group
Dijkstra's Algorithm

Similar to barrera.ppt (20)

PPTX
Dijkstra’s algorithm
PPTX
Dijkstra algorithm a dynammic programming approach
PPTX
dms slide discrete mathematics sem 2 engineering
PDF
Dijkstra Shortest Path Visualization
PPTX
Dijkstra's Algorithm
PPTX
Dijkstras-Algorithm-Finding-the-Shortest-Path.pptx
PDF
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
PPTX
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
PDF
Lecture 16 - Dijkstra's Algorithm.pdf
PPT
2.3 shortest path dijkstra’s
PPTX
Dijkastra’s algorithm
PPTX
Dijkstra's Algorithm
PDF
Djikstra’s Algorithm. Approach to shortest path algorithm with greedy method
PPT
Dijsktra’s Sortest path algorithm
PPTX
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
PDF
04 greedyalgorithmsii 2x2
PDF
Bellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
PPTX
DIJKSTRA_123.pptx
PPT
Jaimin chp-5 - network layer- 2011 batch
PPTX
single source shorest path
Dijkstra’s algorithm
Dijkstra algorithm a dynammic programming approach
dms slide discrete mathematics sem 2 engineering
Dijkstra Shortest Path Visualization
Dijkstra's Algorithm
Dijkstras-Algorithm-Finding-the-Shortest-Path.pptx
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
Lecture 16 - Dijkstra's Algorithm.pdf
2.3 shortest path dijkstra’s
Dijkastra’s algorithm
Dijkstra's Algorithm
Djikstra’s Algorithm. Approach to shortest path algorithm with greedy method
Dijsktra’s Sortest path algorithm
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
04 greedyalgorithmsii 2x2
Bellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
DIJKSTRA_123.pptx
Jaimin chp-5 - network layer- 2011 batch
single source shorest path
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
master seminar digital applications in india
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Classroom Observation Tools for Teachers
PDF
Trump Administration's workforce development strategy
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Microbial diseases, their pathogenesis and prophylaxis
master seminar digital applications in india
A systematic review of self-coping strategies used by university students to ...
Chinmaya Tiranga quiz Grand Finale.pdf
Final Presentation General Medicine 03-08-2024.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Classroom Observation Tools for Teachers
Trump Administration's workforce development strategy
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial disease of the cardiovascular and lymphatic systems
STATICS OF THE RIGID BODIES Hibbelers.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Ad

barrera.ppt

  • 1. DIJKSTRA'S ALGORITHM By Laksman Veeravagu and Luis Barrera
  • 2. THE AUTHOR: EDSGER WYBE DIJKSTRA "Computer Science is no more about computers than astronomy is about telescopes." http://www.cs.utexas.edu/~EWD/
  • 3. EDSGER WYBE DIJKSTRA - May 11, 1930 – August 6, 2002 - Received the 1972 A. M. Turing Award, widely considered the most prestigious award in computer science. - The Schlumberger Centennial Chair of Computer Sciences at The University of Texas at Austin from 1984 until 2000 - Made a strong case against use of the GOTO statement in programming languages and helped lead to its deprecation. - Known for his many essays on programming.
  • 4. SINGLE-SOURCE SHORTEST PATH PROBLEM Single-Source Shortest Path Problem - The problem of finding shortest paths from a source vertex v to all other vertices in the graph.
  • 5. DIJKSTRA'S ALGORITHM Dijkstra's algorithm - is a solution to the single-source shortest path problem in graph theory. Works on both directed and undirected graphs. However, all edges must have nonnegative weights. Approach: Greedy Input: Weighted graph G={E,V} and source vertex v∈V, such that all edge weights are nonnegative Output: Lengths of shortest paths (or the shortest paths themselves) from a given source vertex v∈V to all other vertices
  • 6. DIJKSTRA'S ALGORITHM - PSEUDOCODE dist[s] ←0 (distance to source vertex is zero) for all v ∈ V–{s} do dist[v] ←∞ (set all other distances to infinity) S←∅ (S, the set of visited vertices is initially empty) Q←V (Q, the queue initially contains all vertices) while Q ≠∅ (while the queue is not empty) do u ← mindistance(Q,dist) (select the element of Q with the min. distance) S←S∪{u} (add u to list of visited vertices) for all v ∈ neighbors[u] do if dist[v] > dist[u] + w(u, v) (if new shortest path found) then d[v] ←d[u] + w(u, v) (set new value of shortest path) (if desired, add traceback code) return dist
  • 17. IMPLEMENTATIONS AND RUNNING TIMES The simplest implementation is to store vertices in an array or linked list. This will produce a running time of O(|V|^2 + |E|) For sparse graphs, or graphs with very few edges and many nodes, it can be implemented more efficiently storing the graph in an adjacency list using a binary heap or priority queue. This will produce a running time of O((|E|+|V|) log |V|)
  • 18. DIJKSTRA'S ALGORITHM - WHY IT WORKS  As with all greedy algorithms, we need to make sure that it is a correct algorithm (e.g., it always returns the right solution if it is given correct input).  A formal proof would take longer than this presentation, but we can understand how the argument works intuitively.  If you can’t sleep unless you see a proof, see the second reference or ask us where you can find it.
  • 19.  To understand how it works, we’ll go over the previous example again. However, we need two mathematical results first:  Lemma 1: Triangle inequality If δ(u,v) is the shortest path length between u and v, δ(u,v) ≤ δ(u,x) + δ(x,v)  Lemma 2: The subpath of any shortest path is itself a shortest path.  The key is to understand why we can claim that anytime we put a new vertex in S, we can say that we already know the shortest path to it.  Now, back to the example… DIJKSTRA'S ALGORITHM - WHY IT WORKS
  • 20.  As mentioned, Dijkstra’s algorithm calculates the shortest path to every vertex.  However, it is about as computationally expensive to calculate the shortest path from vertex u to every vertex using Dijkstra’s as it is to calculate the shortest path to some particular vertex v.  Therefore, anytime we want to know the optimal path to some other vertex from a determined origin, we can use Dijkstra’s algorithm. DIJKSTRA'S ALGORITHM - WHY USE IT?
  • 21. APPLICATIONS OF DIJKSTRA'S ALGORITHM - Traffic Information Systems are most prominent use - Mapping (Map Quest, Google Maps) - Routing Systems
  • 22. APPLICATIONS OF DIJKSTRA'S ALGORITHM  One particularly relevant this week: epidemiology  Prof. Lauren Meyers (Biology Dept.) uses networks to model the spread of infectious diseases and design prevention and response strategies.  Vertices represent individuals, and edges their possible contacts. It is useful to calculate how a particular individual is connected to others.  Knowing the shortest path lengths to other individuals can be a relevant indicator of the potential of a particular individual to infect others.
  • 23.  Dijkstra’s original paper: E. W. Dijkstra. (1959) A Note on Two Problems in Connection with Graphs. Numerische Mathematik, 1. 269-271.  MIT OpenCourseware, 6.046J Introduction to Algorithms. < http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer- Science/6-046JFall-2005/CourseHome/> Accessed 4/25/09  Meyers, L.A. (2007) Contact network epidemiology: Bond percolation applied to infectious disease prediction and control. Bulletin of the American Mathematical Society 44: 63-86.  Department of Mathematics, University of Melbourne. Dijkstra’s Algorithm. <http://www.ms.unimelb.edu.au/~moshe/620- 261/dijkstra/dijkstra.html > Accessed 4/25/09 REFERENCES