1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// File PrimMain.cpp
// Build together with Prim.h and Prim.cpp
#include "Prim.h"
void getFigure9_2(vector<list<destV> > & alist);
int main(void){
vector<list<destV> > adjList;
string answer;
cout << "Use default graph? (Y/N): ";
cin >> answer;
if (answer == "Y" || answer== "y"){
getFigure9_2(adjList);
int tw = PrimsAlg(adjList);
cout << "The sum of the edge weights in the MST is " << tw << endl;
}
else {
cout << "TODO: implement reading the adjacency list from a file\n";
return 1;
}
}
void getFigure9_2(vector<list<destV> > & alist){
alist.resize(6); // have 6 vertices
int i,j,w;
int data[6][6] = {
{0,3,0,0,6,5},
{3,0,1,0,0,4},
{0,1,0,6,0,4},
{0,0,6,0,8,5},
{6,0,0,8,0,2},
{5,4,4,5,2,0}};
for (i = 0; i < 6; i++)
for (j = 0; j < 6; j++)
if (w = data[i][j])
alist[i].push_back(destV(char(j+'a'),w));
}
|