The output of Prim's algorithm is a list of edges (and their weights) that constitute a minimum spanning tree. Output the MST into a text file.
In your implementation of Prim's algorithm, implement the priority queue with a binary heap.
Evaluate your code and obtain the running times on the two test graphs – one dense and the other sparse, each with 100000 vertices given to you.
The goal is to write a well-structured and well-documented program to implement Prim's MST algorithm in C/C++.
The input graph is to be read in from a file. The format of the file is as follows: The number of vertices, n, is the first line of the file. The vertices are numbered 0, 1, 2,..., n - 1. Each subsequent line contains two integers, each between 0 and n - 1, indicating the existence of an edge between these two vertices, followed by a number, indicating the weight on the edge. The graph is undirected. For example, a triangle graph in which all the weights are 0.1 would be represented as follows:
3
0 1 0.1
1 2 0.1
2 0 0.1