-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (53 loc) · 2.31 KB
/
main.cpp
File metadata and controls
62 lines (53 loc) · 2.31 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 <iostream>
#include "algorithms/SpannerAlgorithms.h"
#include "utilities/pointsetgenerators.h"
#include "measurements/SpannerMeasurements.h"
using namespace BoundedDegreePlaneSpanners;
void runAlgorithm(const unsigned i, std::vector<Point> &P, std::vector<Edge> &E) {
if (i == 1) BGS05(P, E);
else if (i == 2) LW04(P, E);
else if (i == 3) BSX09(P, E);
else if (i == 4) BGHP10(P, E);
else if (i == 5) KPX10(P, E);
else if (i == 6) KX12(P, E);
else if (i == 7) BCC12<7>(P, E);
else if (i == 8) BCC12<6>(P, E);
else if (i == 9) BKPX15(P, E);
else if (i == 10) KPT17(P, E);
else if (i == 11) BHS18(P, E);
else std::cout << "Invalid choice!" << std::endl;
}
int main() {
// choose a distribution and generate a random pointset
PointGenerator g;
unsigned n = 1000; // set the number of points to be generated
std::vector<Point> P;
g.uni_square(n, 100, P);
/* Other available generators:
g.uni_disk(n, 100, P);
g.normal_clustered(10, n / 10, P);
g.normal_clustered(1, n, P);
g.grid_contiguous(n, P);
g.grid_random(n, P);
g.annulus(n, P);
g.galaxy(n, P);
*/
// Points can also be loaded from files
// Warning: make sure the directory 'realworldpointsets' is present with the desired pointset(s) in it
//g.loadFromFile("../realworldpointsets/Burma.xy",P);
std::vector<Edge> E; // every edge is represented using a pair of point-ids which are its endpoints
CGAL::Real_timer clock;
clock.start();
runAlgorithm(2, P, E); // choose an algorithm
clock.stop();
std::cout << "Time taken: " << clock.time() << " sec." << std::endl;
std::cout << "|P| = " << P.size() << std::endl;
std::cout << "|E| = " << E.size() << std::endl;
std::cout << "Degree: " << degree(E.begin(), E.end()) << std::endl;
std::cout << "Avg. degree: " << avgDegree(E.begin(), E.end()) << std::endl;
std::cout << "Stretch Factor (appx.): " << appxStretchFactor(P.begin(), P.end(),
E.begin(), E.end()) << std::endl;
std::cout << "Stretch Factor (exact.): " << exactStretchFactor(P.begin(), P.end(),
E.begin(), E.end()) << std::endl;
return EXIT_SUCCESS;
}