-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
46 lines (33 loc) · 1.49 KB
/
main.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
43
44
45
46
#include <iostream> // std::cout, std::endl
#include <string> // std::string_literals
#include "karger.h"
#include "read_file.h"
#include "shared_utils.h"
#include "stopwatch_decorator.h"
int main(int argc, char** argv) {
using namespace std::string_literals;
if (argc != 2) {
std::cerr << "1 argument required: filename" << std::endl;
exit(1);
}
const char* filename = argv[1];
std::cout << "filename: "s << filename << std::endl;
// start the stopwatch
const auto program_time_start = stopwatch::now();
// read the graph into an adjacent map
auto graph = read_file(filename);
// number of iterations required by Karger's algorithm to find the min-cut with probability 1/n
const size_t k = utils::estimate_iterations_karger(graph->size());
std::cout << "k: "s << k << '\n';
const auto [min_cut, discovery_time, discovery_iteration, karger_duration] =
stopwatch::decorator<stopwatch::us_t>(karger)(graph, k, program_time_start);
// stop the stopwatch
auto program_time_stop = stopwatch::now();
// executions of the program in microseconds
const auto program_time =
stopwatch::duration<stopwatch::us_t>(program_time_start, program_time_stop);
std::cout << "min_cut: "s << min_cut << std::endl;
std::cout << "program_time: "s << program_time << std::endl;
std::cout << "discovery_time: "s << discovery_time << std::endl;
std::cout << "discovery_iteration: "s << discovery_iteration << std::endl;
}