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

View differences:

custompackages/graph-parser/src/sub_component.cpp
4 4

  
5 5
#include "sub_component.h"
6 6

  
7
SubComponent::SubComponent() {
8
    // do nothing
7
SubComponent::SubComponent(bool weighted_graph) {
8
    // cout << "===> Start SubComponent() constructor, weighted =" << weighted_graph << endl;
9
    gm_ = GraphManager(weighted_graph);
10
    // cout << "<=== Finish SubComponent() constructor\n";
9 11
}
10 12

  
11 13
/* GETTERS & SETTERS & UPDATERS */
......
24 26
StringSet const& SubComponent::non_art_points_id() const {
25 27
    return non_art_points_id_;
26 28
}
29

  
27 30
NameToIntMap const& SubComponent::weight_map() const {
28 31
    // Returns the whole weight_map_, for all the vertices
29 32
    // This one is different from get_weight_map(name)
......
190 193
void SubComponent::CalculateBetweennessCentralityHeuristic() {
191 194
    initialize_betweenness_centrality();
192 195

  
193
    boost::brandes_betweenness_centrality_heuristic(gm_.g_,
194
        traffic_matrix_pmap_,
195
        boost::centrality_map(
196
            v_centrality_pmap_).vertex_index_map(
197
            gm_.v_index_pmap())
198
    );
196
    if (gm_.weighted_graph()) {
197
        cout << "---- Sub Component BC for weighted graph -----\n";
198

  
199
        typedef map<Edge, double> EdgeWeightStdMap;
200
        typedef boost::associative_property_map<EdgeIndexStdMap> EdgeWeightPMap;
201
        EdgeIndexStdMap edge_weight_std_map;
202
        EdgeWeightPMap edge_weight_pmap = EdgeWeightPMap(edge_weight_std_map);
203

  
204
        BGL_FORALL_EDGES(edge, gm_.g_, Graph) {
205
            edge_weight_std_map[edge] = gm_.g_[edge].cost;
206
        }
207

  
208
        boost::brandes_betweenness_centrality_heuristic(gm_.g_,
209
            traffic_matrix_pmap_,
210
            boost::centrality_map(
211
                v_centrality_pmap_).vertex_index_map(
212
                gm_.v_index_pmap()).weight_map(
213
                edge_weight_pmap)
214
        );
215
    }
216
    else {
217
        cout << "---- Sub Component BC for unweighted graph -----\n";
218
        boost::brandes_betweenness_centrality_heuristic(gm_.g_,
219
            traffic_matrix_pmap_,
220
            boost::centrality_map(
221
                v_centrality_pmap_).vertex_index_map(
222
                gm_.v_index_pmap())
223
        );
224
    }
199 225
}
200 226

  
201 227
void SubComponent::initialize_betweenness_centrality() {

Also available in: Unified diff