Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / main.cpp @ 162e1bda

History | View | Annotate | Download (2.16 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
void testHeuristic(string filepath) {
9
    GraphManager gm;
10
    readEdgeFileGraphManager(filepath, gm);
11
    BiConnectedComponents bcc = BiConnectedComponents(gm);
12
    bcc.run();
13
    bcc.print();
14

    
15
    bcc.write_all_betweenness_centrality("../output/simple.edges");
16
    cout << "DONE" << endl;
17
}
18

    
19
void testGraphManager(string filepath) {
20
    GraphManager gm;
21
    readEdgeFileGraphManager(filepath, gm);
22
    gm.print();
23
}
24

    
25
void default_run() {
26
    // input_files = [(filepath, input_type)]
27
    // input_type = 1 ==> edges file
28
    // input_type = 2 ==> simple json file
29
    // input_type = 3 ==> complex json file
30

    
31
    std::list< std::tuple<string, int> > input_files;
32
    // input_files.push_back(std::make_tuple("../input/ninux_unweighted_connected.edges", 1));
33
    // input_files.push_back(std::make_tuple("../input/simple.edges", 1));
34
    input_files.push_back(std::make_tuple("../input/ninux_30_1.edges", 1));
35
    // input_files.push_back(std::make_tuple("../input/olsr-netjson.json", 2));
36
    // input_files.push_back(std::make_tuple("../input/jsoninfo_topo.json", 3));
37

    
38
    for (auto input : input_files) {
39
        string filepath = std::get<0>(input);
40
        int input_type = std::get<1>(input);
41
        GraphManager gm;
42
        if (input_type == 1) {
43
            readEdgeFileGraphManager(filepath, gm);
44
        }
45
        else if (input_type == 2) {
46
            readJsonGraphManager(filepath, gm);
47
        }
48
        else if (input_type == 3) {
49
            readComplexJsonGraphManager(filepath, gm);
50
        }
51

    
52
        cout << gm;
53

    
54
        BiConnectedComponents bcc = BiConnectedComponents(gm);
55
        bcc.run();
56
        // bcc.print();
57
        string filename = helper::get_file_name(filepath);
58
        string out_filepath = "../output/" + filename + ".out";;
59
        bcc.write_all_betweenness_centrality(out_filepath);
60
    }
61
}
62

    
63
void old_main_code() {
64
    string simpleGraphfilepath = "../input/simple.edges";
65
    testGraphManager(simpleGraphfilepath);
66

    
67
    testHeuristic(simpleGraphfilepath);
68
}
69

    
70
int main(int, char *[]) {
71
    default_run();
72

    
73
    return 0;
74
}