```
**hello peeps and geeks, i am missing the MinSpanningTree function here.. any help please? need to fill up the function to get
a) Minimum spanning tree cost for the graph
b)Spanning tree path for the graph. E.g in matrix or adjancency list.
**
#include <iostream>
#include <ctime> // For time()
#include <cstdlib> // 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; i++)
{ for (int j =0;j<N; j++)
cout<<" "<<AdjMat[i][j];
cout<<endl;
}
int status= 0;
for (int i =0;i<N; i++)
{ for (int j =0;j<N; j++)
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;
}
```

electrodelic
0
Newbie Poster

## Recommended Answers

Jump to Post`F = Ø // Initialize set of edges // to empty. Y = {v1} // Initialize set of vertices to // contain only the first one. while (the instance is not solved){ select a vertex in V - Y that is // selection procedure and nearest to …`

## All 2 Replies

Reply to this topic
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.