root / custompackages / graph-parser / src / main.cpp @ 20756421
History | View | Annotate | Download (2.46 KB)
1 |
#include <iostream> |
---|---|
2 |
#include "parser.h" |
3 |
#include "utility.h" |
4 |
#include "centrality.h" |
5 |
#include "bi_connected_components.h" |
6 |
#include "graph_manager.h" |
7 |
|
8 |
|
9 |
void handleSimpleGraph() {
|
10 |
/* I don't understand the output. Why there are 8 vertices?
|
11 |
Simple graph
|
12 |
0
|
13 |
1
|
14 |
2
|
15 |
3
|
16 |
4
|
17 |
5
|
18 |
6
|
19 |
7
|
20 |
8
|
21 |
*/
|
22 |
typedef boost::adjacency_list<> G;
|
23 |
G a; |
24 |
{ |
25 |
boost::graph_traits<G>::vertex_descriptor v, u, t; |
26 |
u = vertex(1, a);
|
27 |
v = vertex(8, a);
|
28 |
// t = vertex(5, a);
|
29 |
add_edge(u, v, a); |
30 |
// add_edge(u, t, a);
|
31 |
} |
32 |
|
33 |
std::set<typename boost::graph_traits<G>::vertex_descriptor> av;
|
34 |
cout << "Simple graph" << endl;
|
35 |
BGL_FORALL_VERTICES_T(v, a, G) { |
36 |
cout << v << endl; |
37 |
} |
38 |
} |
39 |
void handleSimpleInput(string filePath) { |
40 |
// Read the input.edges
|
41 |
Graph g; |
42 |
readEdgeFile(filePath, g); |
43 |
|
44 |
cout << "Finish creating graph" << endl;
|
45 |
|
46 |
simpleBetweennessCentrality(g, "edge_list");
|
47 |
} |
48 |
|
49 |
void handleJsonInput(string filePath) { |
50 |
Graph g; |
51 |
readJson(filePath, g); |
52 |
outops::operator<<(cout, g);
|
53 |
|
54 |
// Applying the betweenness centrality
|
55 |
simpleBetweennessCentrality(g, "json_olsr");
|
56 |
|
57 |
cout << "Done with Betweenness Centrality" << endl;
|
58 |
} |
59 |
|
60 |
void handleComplexJsonInput(string filePath) { |
61 |
Graph g; |
62 |
readComplexJson(filePath, g); |
63 |
outops::operator<<(cout, g);
|
64 |
|
65 |
// Applying the betweenness centrality
|
66 |
simpleBetweennessCentrality(g, "json_topology");
|
67 |
|
68 |
cout << "Done with Betweenness Centrality" << endl;
|
69 |
} |
70 |
|
71 |
void testHeuristic(string filePath) { |
72 |
GraphManager gm; |
73 |
readEdgeFileGraphManager(filePath, gm); |
74 |
BiConnectedComponents bcc(gm); |
75 |
cout << "DONE" << endl;
|
76 |
} |
77 |
|
78 |
void testGraphManager(string filePath) { |
79 |
GraphManager gm; |
80 |
readEdgeFileGraphManager(filePath, gm); |
81 |
cout << gm; |
82 |
|
83 |
gm.ResetVerticesAndEdgesIndexMap(); |
84 |
gm.print_v_index_map(); |
85 |
|
86 |
} |
87 |
|
88 |
int main(int, char *[]) { |
89 |
// string edgeFilePath = "../input/ninux_30_1.edges";
|
90 |
// testHeuristic(edgeFilePath);
|
91 |
// handleSimpleInput(edgeFilePath);
|
92 |
//
|
93 |
// string jsonFilePath = "../input/olsr-netjson.json";
|
94 |
// handleJsonInput(jsonFilePath);
|
95 |
//
|
96 |
// string complexJsonFilePath = "../input/jsoninfo_topo.json";
|
97 |
// handleComplexJsonInput(complexJsonFilePath);
|
98 |
|
99 |
// string simpleGraphFilePath = "../input/simple.edges";
|
100 |
// testGraphManager(simpleGraphFilePath);
|
101 |
|
102 |
string simpleGraphFilePath = "../input/simple.edges"; |
103 |
testHeuristic(simpleGraphFilePath); |
104 |
|
105 |
return 0; |
106 |
} |