Question
Implement Dijkstras algorithm for computing a shortest path from a designated vertex (A) to a designated vertex (B) in a directed graph. Your implementation should
Implement Dijkstra’s algorithm for computing a shortest path from a designated vertex (A) to a designated vertex (B) in a directed graph. Your implementation should use a minimum heap as a supporting data structure. Please follow the instructions below.
• Programming languages. You can use any standard programming language such as C, C++, Visual C++, C#, Java, or Python.
• Program requirements. Your program should read the graph from a text file (assumed to be in the same folder as the source code) that has the same format as the input files uploaded on D2L (in the same folder as the assignment). Each input file starts with a line containing the number of vertices in the graph. The vertices are assumed to be numbered alphabetically starting with vertex A. Each subsequent line in the input file contains the tail of an edge followed by a space, the head of the edge followed by a space, and the weight of the edge, respectively. Your program should output the weight of a shortest path from vertex A to vertex B in the graph and the sequence of vertices on a shortest path from A to B; the format of the output should match the format of the solution files uploaded on D2L (same folder).
• Material to be submitted. The files containing your source code. Make sure that the files compile and run. The grader will test your programs on the uploaded test files (text files). So make sure that your programs run on the uploaded files.
Case 1
10
A J 18
A H 79
A I 81
J G 24
J F 76
G F 2
G H 50
F E 4
E D 2
D H 20
H C 50
I D 6
I C 97
I J 27
C B 22
Case 2
15
A O 100
A G 16
A C 17
A J 2
O B 100
G E 7
C K 10
C M 5
C J 12
K E 11
K G 33
E O 27
E H 25
E L 6
L B 16
L D 32
H B 24
D B 18
J N 14
M O 24
M F 25
F B 3
N F 31
N I 50
I B 34
I D 19
Case 3
20
A D 30
A E 93
A C 79
C I 10
C E 50
D H 32
D E 50
E H 50
E L 14
E J 88
E I 18
L H 50
L I 69
L F 32
L K 78
I J 63
I F 50
H M 55
H K 71
J G 75
J B 92
J N 57
F J 61
F N 53
F K 28
K G 28
K B 86
G Q 3
G B 100
Q B 50
Q P 50
N B 61
N S 26
M O 79
M R 50
R O 23
R T 14
S R 4
S P 50
S Q 50
T P 32
T N 18
P B 50
P N 50
ReadMe
The starting point is labeled A
The termination point is labeled B
Step by Step Solution
3.46 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
Python2 code for the Dijkstras Algorithmfrom collections import defaultdict import sys class Heap def initself selfarray selfsize 0 selfpos def newMin...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started