``````**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;

{
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<<endl;
}

int status= 0;
for (int i =0;i<N; i++)
{ for (int j =0;j<N; j++)
if (i==j)
{ status = 1;
i = N; j = N;
}
}
else
{ status = 1; i = N; j=N;
}
}
}
if (status == 1)
cout<<" Error in Adjacency Matrix \n";
else
cout<<" Adjacency Matrix is correct \n ";

// system("pause");
return 0;
}
``````

All 2 Replies

``````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 Y                       // feasibility check

if (Y == V)                        // solution check
the instance is solved;
}
``````

Had this pseudocode from my text book.

Hope that helps :)