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

Dijkstras algorithm

Dijkstra's algorithm is a solution for the single-source shortest path problem in graph theory, applicable to both directed and undirected graphs with nonnegative edge weights. It uses a greedy approach to find the shortest paths from a source vertex to all other vertices in a weighted graph. The output includes the lengths of the shortest paths or the paths themselves.

Uploaded by

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

Dijkstras algorithm

Dijkstra's algorithm is a solution for the single-source shortest path problem in graph theory, applicable to both directed and undirected graphs with nonnegative edge weights. It uses a greedy approach to find the shortest paths from a source vertex to all other vertices in a weighted graph. The output includes the lengths of the shortest paths or the paths themselves.

Uploaded by

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

Dijkstra's algorithm

1
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.

2
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

3
Dijkstra's algorithm - Pseudocode

4
Dijkstra Animated Example-1

5
Dijkstra Animated Example-1

6
Dijkstra Animated Example-1

7
Dijkstra Animated Example-1

8
Dijkstra Animated Example-1

9
Dijkstra Animated Example-1

10
Dijkstra Animated Example-1

11
Dijkstra Animated Example-2

12
Dijkstra Animated Example-2

13
Dijkstra Animated Example-2

14
Dijkstra Animated Example-2

15
Dijkstra Animated Example-2

16
Dijkstra Animated Example-2

17
Dijkstra Animated Example-2

18
Dijkstra Animated Example-2

19
Dijkstra Animated Example-2

Shortest Path from A to H,


A to C, C to D, D to E, E to G, G to F, F to H
20
End
21

You might also like