Revision d5b7a27f custompackages/graph-parser/src/main.cpp

View differences:

custompackages/graph-parser/src/main.cpp
22 22
    gm.print();
23 23
}
24 24

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

  
31 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));
32
    input_files.push_back(std::make_tuple("../input/simple.edges", 1));
33
    input_files.push_back(std::make_tuple("../input/ninux_unweighted_connected.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 36
    input_files.push_back(std::make_tuple("../input/jsoninfo_topo.json", 3));
37 37

  
38 38
    for (auto input : input_files) {
39 39
        string filepath = std::get<0>(input);
40 40
        int input_type = std::get<1>(input);
41
        GraphManager gm;
41

  
42
        GraphManager gm(is_weighted_graph);
43

  
42 44
        if (input_type == 1) {
43 45
            readEdgeFileGraphManager(filepath, gm);
44 46
        }
......
51 53

  
52 54
        gm.print();
53 55

  
54
        BiConnectedComponents bcc = BiConnectedComponents(gm, false);
56
        BiConnectedComponents bcc = BiConnectedComponents(gm);
55 57
        bcc.run();
58

  
59
        // Calculate Betweenness Centrality
60
        cout << "Calculate Betweenness Centrality\n";
61
        bcc.CalculateBetweennessCentrality(targets_inclusion);
56 62
        // bcc.print();
57
        string filename = helper::get_file_name(filepath);
58
        string out_filepath = "../output/" + filename + ".out";;
63

  
64
        string filename;
65
        string ext;
66
        helper::get_file_name_and_extension(filepath, filename, ext);
67

  
68
        string out_filepath = "../output/" + filename;
69
        if (is_weighted_graph) {
70
            out_filepath += "_weighted.out";
71
        }
72
        else {
73
            out_filepath += "_unweighted.out";
74
        }
59 75
        bcc.write_all_betweenness_centrality(out_filepath);
60 76
    }
61 77
}
......
67 83
    testHeuristic(simpleGraphfilepath);
68 84
}
69 85

  
70
int main(int, char *[]) {
71
    default_run();
86
int main(int argc, char * argv[]) {
87
    bool is_weighted_graph = true;
88
    bool targets_inclusion = true;
89

  
90
    if (argc >= 2) {
91
        string argument(argv[1]);
92
        if (argument.compare("false") == 0) {
93
            is_weighted_graph = false;
94
        }
95

  
96
        if (argc > 2) {
97
           argument = string(argv[2]);
98
            if (argument.compare("false") == 0) {
99
                targets_inclusion = false;
100
            }
101
        }
102
    }
103

  
104
    default_run(is_weighted_graph, targets_inclusion);
72 105

  
106
    cout << "is weighted graph  = " << is_weighted_graph << endl;
73 107
    return 0;
74 108
}

Also available in: Unified diff