Revision 33e5ad95 custompackages/graph-parser/src/bi_connected_components.cpp

View differences:

custompackages/graph-parser/src/bi_connected_components.cpp
122 122
    calculate_bc_inter();
123 123

  
124 124
    for (int i = 0; i < num_of_bcc_; ++i) {
125
        // cout << "BC for component " << i << endl;
126 125
        BCCs[i].CalculateBetweennessCentralityHeuristic();
127 126
    }
128 127

  
......
131 130
        // For all points
132 131
        for (string id: BCCs[i].all_vertices_id()) {
133 132
            score = BCCs[i].get_betweenness_centrality(id);
134
            // cout << "XXX score from component << " << i << ", id " << id << " = " << score << endl;
135 133
            bc_score_[id] += score;
136 134
        }
137 135
    }
138 136

  
139
    // // Sum the BC for each sub-component
140
    // for (int i = 0; i < num_of_bcc_; ++i) {
141
    //     // For non articulation points
142
    //     for (string id: BCCs[i].non_art_points_id()) {
143
    //         score = BCCs[i].get_betweenness_centrality(id);
144
    //         bc_score_[id] = score;
145
    //     }
146

  
147
    //     // For articulation points
148
    //     for (string id: BCCs[i].art_points_id()) {
149
    //         score = BCCs[i].get_betweenness_centrality(id);
150
    //         bc_sum_art_points_[id] += score;
151
    //     }
152
    // }
153

  
154 137
    // Update the BC score for articulation points
155 138
    for (string id : all_art_points_id_) {
156
    //     bc_score_[id] = bc_sum_art_points_[id];
157

  
158
        // TODO: Jan 29, 2015: for now, I do not minus the bc_inter_
159
        cout << bc_score_[id] << " --> ";
160 139
        bc_score_[id] -= bc_inter_[id];
161
    //     cout << bc_score_[id] << endl;
162 140
    }
163 141

  
164 142
    finalize_betweenness_centrality_heuristic();
......
167 145
}
168 146

  
169 147
// BETWEENNESS CENTRALITY - NORMAL CALCULATION
170
void BiConnectedComponents::CalculateBetweennessCentrality(bool targets_inclusion) {
148
void BiConnectedComponents::CalculateBetweennessCentrality(bool endpoints_inclusion) {
171 149
    initialize_betweenness_centrality();
172 150

  
173 151
    if (gm_.weighted_graph()) { // calculate BC for weighted graph
......
181 159
        BGL_FORALL_EDGES(edge, gm_.g_, Graph) {
182 160
            edge_weight_std_map[edge] = gm_.g_[edge].cost;
183 161
        }
184
        boost::brandes_betweenness_centrality_targets_inclusion(gm_.g_,
185
            targets_inclusion,
162
        boost::brandes_betweenness_centrality_endpoints_inclusion(gm_.g_,
163
            endpoints_inclusion,
186 164
            boost::centrality_map(
187 165
                v_centrality_pmap_).vertex_index_map(
188 166
                gm_.v_index_pmap()).weight_map(
......
190 168
        );
191 169
    }
192 170
    else { // for unweighted graph
193
        boost::brandes_betweenness_centrality_targets_inclusion(gm_.g_,
194
            targets_inclusion,
171
        boost::brandes_betweenness_centrality_endpoints_inclusion(gm_.g_,
172
            endpoints_inclusion,
195 173
            boost::centrality_map(
196 174
                v_centrality_pmap_).vertex_index_map(
197 175
                gm_.v_index_pmap())
......
502 480
            bc_inter_[id] += BCCs[i].get_weight_map(id) * BCCs[i].get_weight_reversed_map(id);
503 481
        }
504 482
    }
483

  
484
    if (!gm_.weighted_graph()) {
485
        for (string id : all_art_points_id_) {
486
            bc_inter_[id] /= 2;
487
        }
488
    }
505 489
}
506 490

  
507 491
void BiConnectedComponents::finalize_betweenness_centrality_heuristic() {

Also available in: Unified diff