Prims
Prims
#include <unordered_map>
#include <vector>
#include <climits>
using namespace std;
class Graph {
int n;
int adj[100][100];
unordered_map<string, int> nodeToIndex;
vector<string> indexToNode;
int nodeCount = 0;
public:
Graph(int nodes) {
n = nodes;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
adj[i][j] = 0;
}
}
}
void primMST() {
int parent[100];
int key[100];
bool visited[100];
int totalWeight = 0;
key[0] = 0;
parent[0] = -1;
cout << "\nTotal Weight of MST: " << totalWeight << endl;
}
};
int main() {
int e;
cout << "\nEnter number of Edges: ";
cin >> e;
g.primMST();
return 0;
}
Test Case 1:
Test Case 2:
Test Case 3: