-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (55 loc) · 1.53 KB
/
main.cpp
File metadata and controls
74 lines (55 loc) · 1.53 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
63
64
65
66
67
68
69
70
71
72
73
#include <fstream>
#include "eagle.h"
using namespace std;
int main(int argc, char *argv[]) {
int mode;
const char *src = "";
const char *dest = "";
int nthreads;
cout << "argc: " << argc << endl;
switch (argc) {
case 3:
mode = 1;
nthreads = atoi(argv[1]);
src = argv[2];
break;
case 4:
mode = 2;
nthreads = atoi(argv[1]);
src = argv[2];
dest = argv[3];
break;
default:
cerr << "Sinopsi: " << argv[0] << " nThreads src [dest]" << endl;
return EXIT_FAILURE;
}
cout << "EAGLE" << endl;
cout << "Caricato su: " << src << endl;
if (mode == 2) cout << "Salvataggio dati su: " << dest << endl;
cout << "Numero di thread usati: " << nthreads << endl;
omp_set_num_threads(nthreads);
igraph_i_set_attribute_table(&igraph_cattribute_table);
int result;
igraph_t graph;
FILE *instream = fopen(src, "r");
if (instream == NULL) {
cerr << "File non esistente." << endl;
return EXIT_FAILURE;
}
cout << "Lettura grafo" << endl;
result = igraph_read_graph_graphml(&graph, instream, 0);
cout << "OK." << endl;
fclose(instream);
EAGLE e(&graph);
Communities *r = e.run();
cout << r->summary(mode == 1) << endl;
if (mode == 2) {
ofstream ofs(dest);
r->dump(ofs);
ofs.close();
}
// liberiamo la memoria
r->free();
delete r;
return EXIT_SUCCESS;
}