0% found this document useful (0 votes)
2 views

Dijkstra Algorithm

Dijkstra's Algorithm is a method in graph theory for finding the shortest paths from a source vertex to all other vertices in both directed and undirected graphs, provided all edge weights are non-negative. The document outlines the procedure, pseudocode, and examples of the algorithm, as well as discusses its running times and time complexity. It highlights that the simplest implementation uses an array or linked list, while more efficient implementations utilize an adjacency list with a binary heap or priority queue.

Uploaded by

sibugrow598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Dijkstra Algorithm

Dijkstra's Algorithm is a method in graph theory for finding the shortest paths from a source vertex to all other vertices in both directed and undirected graphs, provided all edge weights are non-negative. The document outlines the procedure, pseudocode, and examples of the algorithm, as well as discusses its running times and time complexity. It highlights that the simplest implementation uses an array or linked list, while more efficient implementations utilize an adjacency list with a binary heap or priority queue.

Uploaded by

sibugrow598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Dijkstra’s Algorithm

• It is a single-source shortest path problem or


algorithm in the graph theory.
• It is used for finding shortest paths from a
source vertex u to all other vertices in the
graph.
• This works on both directed and undirected
graphs.
• All the edges must have non-negative weights.
Procedure
Pseudocode
Example

u A B C D E
π N N N N N
Cont…
Cont…

u A B C D E
π N A A N N
Cont…

u A B C D E
π N A A N N
Cont…

u A B C D E
π N C A C C
Cont…

u A B C D E
π N C A C C
Cont…

u A B C D E
π N C A C C
Cont…

u A B C D E
π N C A B C
Cont…

u A B C D E
π N C A B C
Cont…

u A B C D E
π N C A B C
Cont…

Shortest Path

u A B C D E
π N C A B C
Running Times
• The simplest implementation is to store
vertices in an array or linked list. This will
produce a running time of
• For any graphs with very few edges and many
nodes or vertices, 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
Time Complexity: Using Linked list

You might also like