forked from franktakes/teexgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (40 loc) · 1.29 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
47
48
49
50
51
/*
* teexGraph --- by Frank Takes --- https://github.com/franktakes/teexgraph
*
* Example main-file showing how to use teexGraph
*/
#include "Graph.h"
#include "Timer.h"
using namespace std;
// if compiled with "make listener", start the listener and ignore this file
#if runlistener == 1
#include "listener.h"
int main(const int argc, const char* argv[]) { Graph G; return listener(G); }
#else
// if compiled with reguler "make" command, run this main function
#include "examples.h"
int main(const int argc, const char* argv[]) {
// catch no input graph given in command line parameter
if(argc < 2) {
cerr << "Error: first argument should be the network filename." << endl;
return 1;
}
// timer object to measure loading and computation time
Timer T;
T.click();
// create and load graph from file. pass an int >= nodecount
// to optimize memory usage or if you want to have a nodecount > 10M nodes
Graph G;
if(!G.loadUndirected(argv[1]))
return 1;
// detect weakly connected components
G.computeWCC();
// show some statistics of the network
stats(G); // from examples.cpp
T.click();
// compute the diameter of the largest WCC of this network
cout << G.diameterBD() << endl;
T.click();
return 0;
}
#endif