Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / main.cpp @ ee0dd796

History | View | Annotate | Download (2.28 KB)

1
#include <iostream>
2
#include "parser.h"
3
#include "utility.h"
4
#include "centrality.h"
5
#include "bi_connected_components.h"
6

    
7

    
8
void handleSimpleGraph() {
9
    /* I don't understand the output. Why there are 8 vertices?
10
        Simple graph
11
        0
12
        1
13
        2
14
        3
15
        4
16
        5
17
        6
18
        7
19
        8
20
    */
21
    typedef boost::adjacency_list<> G;
22
    G a;
23
    {
24
        boost::graph_traits<G>::vertex_descriptor v, u, t;
25
        u = vertex(1, a);
26
        v = vertex(8, a);
27
        // t = vertex(5, a);
28
        add_edge(u, v, a);
29
        // add_edge(u, t, a);
30
    }
31

    
32
    std::set<typename boost::graph_traits<G>::vertex_descriptor> av;
33
    cout << "Simple graph" << endl;
34
    BGL_FORALL_VERTICES_T(v, a, G) {
35
        cout << v << endl;
36
    }
37
}
38
void handleSimpleInput(string filePath) {
39
    // Read the input.edges
40
    Graph g;
41
    readEdgeFile(filePath, g);
42

    
43
    cout << "Finish creating graph" << endl;
44

    
45
    simpleBetweennessCentrality(g, "edge_list");
46
}
47

    
48
void handleJsonInput(string filePath) {
49
    Graph g;
50
    readJson(filePath, g);
51
    printGraph(g);
52

    
53
    // Applying the betweenness centrality
54
    simpleBetweennessCentrality(g, "json_olsr");
55

    
56
    cout << "Done with Betweenness Centrality" << endl;
57
}
58

    
59
void handleComplexJsonInput(string filePath) {
60
    Graph g;
61
    readComplexJson(filePath, g);
62
    printGraph(g);
63

    
64
    // Applying the betweenness centrality
65
    simpleBetweennessCentrality(g, "json_topology");
66

    
67
    cout << "Done with Betweenness Centrality" << endl;
68
}
69

    
70
void testHeuristic(string filePath) {
71
    Graph g;
72
    readEdgeFile(filePath, g);
73
    outops::operator<<(cout, g);
74
    BiConnectedComponents bcc(g);
75
    // bcc.compute_weight();
76
    // bcc.findBetweennessCentrality();
77
    // bcc.printBetweennessCentrality();
78
    // bcc.print_weight();
79
    // bcc.print();
80
    cout << "DONE" << endl;
81

    
82

    
83
}
84

    
85
int main(int, char *[]) {
86
//    string edgeFilePath = "../input/ninux_30_1.edges";
87
//    testHeuristic(edgeFilePath);
88
//    handleSimpleInput(edgeFilePath);
89
//
90
//    string jsonFilePath = "../input/olsr-netjson.json";
91
//    handleJsonInput(jsonFilePath);
92
//
93
//    string complexJsonFilePath = "../input/jsoninfo_topo.json";
94
//    handleComplexJsonInput(complexJsonFilePath);
95

    
96

    
97
    string simpleGraphFilePath = "../input/simple.edges";
98
    testHeuristic(simpleGraphFilePath);
99
    return 0;
100
}