-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (42 loc) · 1.83 KB
/
Copy pathmain.cpp
File metadata and controls
62 lines (42 loc) · 1.83 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "buildData.hpp"
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(int argc, char* argv[]) {
//start timing
clock_t mainStart = clock();
string filename = argv[1]; // Filename of input
vector<v*> Vertices; // Container for cities, v is a struct (see buildData.hpp)
int n = 0; // Number of cities
int ** Distances = NULL;
vector<int> Tour;
// Matrix for distances between cities
cout << "\n- Reading Data --------------------------- " << endl;
n = readData(Vertices, filename);
cout << "\n- Building Data --------------------------- " << endl;
Distances = buildMatrix(Vertices, n);
buildMST(Vertices, Distances, n);
perfectMatching(Vertices, Distances);
Tour = find_tour(Vertices, 0, Distances);
cout << "\n- Outputting Data to file: " << filename <<".tour" << endl;
outputSolution(Tour, filename);
//output timing
clock_t mainEnd = clock();
double time = (double) (mainEnd - mainStart) / CLOCKS_PER_SEC;
std::cout << "\nTotal running time: " << time << " secs" << std::endl;
/**//* Optional -------------------------------------------------------------------------------------- */
/**/
/**/ //cout << "\n- Output Data ----------------------------- " << endl;
/**/
/** _printDistanceMatrix(Distances, n, "outputDistanceMatrix.txt"); // take away the string argument to print to screen
/** printMSTLinklist(Vertices, n);
/** printMSTMatrix(Vertices, n, "outputMST.txt"); // take away the string argument to print to screen
/**/
/**//*--------------------------------------------------------------------------------------------------*/
//cout << "\n- Clean up Data --------------------------- " << endl;
clean_D(Distances, n);
clean_V(Vertices);
return 0;
}