Description
Let G=(V,E)
be an undirected, connected, weighted graph who is represented as an adjacency matrix. Find the minimum spanning tree of G. A minimum spanning tree is a least-cost subset of the edges of a graph that connects all the nodes.
Input Format
An ∣V∣×∣V∣
adjacency matrix such that
Edge weights are integers in the range of [1, 255].
Output Format
The summation of the edge weights of the minimum spanning tree.
Example
Input:
0 2 0 6 0
2 0 3 8 5
0 3 0 0 7
6 8 0 0 9
0 5 7 9 0
Output:
16
Reference Code
// Add any standard library if needed.
#include <iostream>
#include <vector>
using namespace std;
// Implement your minimum spanning tree algorithm
// Test your implementation
int main()
{
}