Question: Question: implementing Dijkstra's algorithm in c++ language to compute the shortest path from a designated vertex (A) to a designated vertex (B) in a directed
Question: implementing Dijkstra's algorithm in c++ language to compute the shortest path from a designated vertex (A) to a designated vertex (B) in a directed graph, and the text file content used as the input are below:
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
It starts with an int which is the number of vertices in the graph. The vertices are assumed to be numbered alphabetically starting with vertex A. Each subsequent line in the text 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.
Write a program in c++ which will get this text file as input file, and 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 1 A to B.
The resuilt from the above text file is:
45 A G E L B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
