Hi guys, any one here can help me to complete the MinSpanningTreefunction ?
a) Minimum spanning tree cost for the graph
b)Spanning tree path for the graph. E.g in matrix or adjancency list.
**********
#include
#include // For time()
#include // For srand() and rand()
#define N 6
#define infinity 9999999
using namespace std;
void MinSpanningTree(int AdjMat[N][N])
{
cout<<" The minimal Spanning Tree cost is ";
cout<<"The minimal Spanning path is ";
// A B C D
}
int main ()
{
int AdjMat[N][N] = { 0, 1, infinity, 2, infinity, infinity, // Node A
1, 0, 2, infinity, infinity, 3, // Node B
infinity, 2, 0, infinity, infinity, infinity, // Node C
2, infinity, infinity, 0, 5, 1, // Node D
infinity, infinity, infinity, 5, 0, 4, // Node E
infinity, 3, infinity, 1,4, 0 // Node F
};
// Connectivity Initization
for (int i =0;i<n;> { for (int j =0;j<n;> cout<<" "<<AdjMat[i][j];
cout<<endl;
}
int status= 0;
for (int i =0;i<n;> { for (int j =0;j<n;> if (i==j)
{ if (AdjMat[i][j] != 0)
{ status = 1;
i = N; j = N;
}
}
else
{ if (AdjMat[i][j]!= AdjMat[j][i])
{ status = 1; i = N; j=N;
}
}
}
if (status == 1)
cout<<" Error in Adjacency Matrix \n";
else
cout<<" Adjacency Matrix is correct \n ";
MinSpanningTree(AdjMat);
// system("pause");
return 0;
}