The document contains a C++ program that implements Dijkstra's algorithm using a greedy method to find the shortest paths from a source vertex in a directed graph. It includes a class definition for the graph, methods to prepare the adjacency list, and to compute distances using Dijkstra's algorithm. The program prompts the user for the number of vertices and edges, and outputs the shortest distances from the source vertex to all other vertices.
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 ratings0% found this document useful (0 votes)
5 views3 pages
DAA Program-5
The document contains a C++ program that implements Dijkstra's algorithm using a greedy method to find the shortest paths from a source vertex in a directed graph. It includes a class definition for the graph, methods to prepare the adjacency list, and to compute distances using Dijkstra's algorithm. The program prompts the user for the number of vertices and edges, and outputs the shortest distances from the source vertex to all other vertices.
UNIVERSITY INSTITUTE OF ENGINEERING AND TECHNOLOGY (A CONSTITUENT AUTONOMOUS INSTITUTE AND RECOGNIZED BY UGC UNDER SECTION 12(B) AND 2(F)) KURUKSHETRA UNIVERSITY, KURUKSHETRA (ESTABLISHED BY THE S