-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.cpp
42 lines (35 loc) · 978 Bytes
/
example.cpp
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
#include <iomanip>
#include <iostream>
#include <fstream>
#include <vector>
#include <memory>
#include <string>
#include "emst/emst.hpp"
using namespace std;
template<size_t DIM>
void example() {
fstream fin("../test_data/dim" + to_string(DIM) + ".txt");
size_t n; fin >> n;
vector<Point<DIM>> points(n);
for (size_t i = 0; i < n; i++) {
for (size_t k = 0; k < DIM; k++) {
fin >> points[i][k];
}
}
string s; fin >> s;
double answer; fin >> answer;
KdTreeSolver<DIM> solver_fast(points);
PrimSolver<DIM> solver_slow(points);
cout << DIM << "-dimensional space:" << endl;
cout << "Answer: " << answer << endl;
cout << "Fast solver answer: " << solver_fast.get_total_length() << endl;
cout << "Slow solver answer: " << solver_slow.get_total_length() << endl;
cout << endl;
}
int main() {
cout.setf(ios::fixed);
cout.precision(6);
example<2>();
example<10>();
return 0;
}