Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / main.cpp @ 437fd680

History | View | Annotate | Download (2.45 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
    gm.print();
75
    BiConnectedComponents bcc = BiConnectedComponents(gm);
76
    cout << bcc;
77
    cout << "DONE" << endl;
78
}
79

    
80
void testGraphManager(string filePath) {
81
    GraphManager gm;
82
    readEdgeFileGraphManager(filePath, gm);
83
    gm.print();
84
}
85

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

    
97
    // string simpleGraphFilePath = "../input/simple.edges";
98
    // testGraphManager(simpleGraphFilePath);
99

    
100
    string simpleGraphFilePath = "../input/simple.edges";
101
    testHeuristic(simpleGraphFilePath);
102

    
103
    return 0;
104
}