Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / sub_component.h @ 437fd680

History | View | Annotate | Download (2.76 KB)

1
//
2
// Created by quynh on 1/9/16.
3
//
4

    
5
// Problem with deep copy
6
// http://stackoverflow.com/questions/6955578/subtraction-and-intersection-of-two-vectors-of-pointers-in-c
7

    
8
#ifndef GRAPH_PARSER_SUB_COMPONENT_H
9
#define GRAPH_PARSER_SUB_COMPONENT_H
10

    
11
#include <boost/graph/betweenness_centrality.hpp>
12
#include <boost/graph/copy.hpp>
13
#include "common.h"
14
#include "utility.h"
15
#include "graph_manager.h"
16

    
17
class SubComponent {
18
public:
19
    typedef std::vector<double> CentralityVec;
20
    typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
21

    
22
    SubComponent();
23

    
24
    // Getter & Setter
25
    GraphManager const& gm() const;
26
    StringSet const& all_vertices_id() const;
27
    StringSet const& art_points_id() const;
28
    StringSet const& non_art_points_id() const;
29

    
30
    NameToIntMap const& weight_map() const;
31
    NameToIntMap const& weight_reversed_map() const;
32

    
33
    vector< vector< int > > const& traffic_matrix() const;
34

    
35
    CentralityVec const& v_centrality_vec() const;
36

    
37
    // CREATE SUB-COMPONENT
38
    void AddEdge(Router r1, Router r2, Link l);
39
    void FinalizeSubComponent(StringSet all_art_points_id);
40

    
41
    // LINK WEIGHT CALCULATION
42
    void initialize_weight();
43
    int get_weight_map(string name);
44
    int get_weight_reversed_map(string name);
45
    void update_weight_map(string name, int value);
46

    
47
    // TRAFFIC MATRIX CALCULATION
48
    void CalculateTrafficMatrix();
49
    void initialize_traffic_matrix();
50
    int get_traffic_matrix(string name_1, string name_2);
51
    void update_traffic_matrix(string name_1, string name_2, int value);
52

    
53
    // BETWEENNESS CENTRALITY
54
    void CalculateBetweennessCentrality();
55
    void initialize_betweenness_centrality();
56
    double get_betweenness_centrality(string name);
57
    double get_betweenness_centrality(Vertex v);
58

    
59
    // HELPERS
60
    int num_of_vertices();
61
    int index_of_vertex_id(string vertex_id);
62
    bool vertex_exists(string name);
63
    string first_vertex_id_with_unknown_weight();
64

    
65
    // HELPERS FOR OUTPUTTING RESULT
66
    void print();
67
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
68
    void print_traffic_matrix();
69

    
70

    
71
    // OLD CODE
72
    void printWeight();
73
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
74

    
75
    // Betweenness Centrality
76

    
77
    void findBetweennessCentrality();
78
    void printBetweennessCentrality();
79

    
80
    // NEW CODE
81
    GraphManager gm_;
82

    
83
private:
84
    StringSet all_vertices_id_;
85
    StringSet art_points_id_;
86
    StringSet non_art_points_id_; // vertices that are not articulation points
87
    NameToIntMap name_index_pmap_;
88

    
89

    
90
    NameToIntMap weight_map_;
91
    NameToIntMap weight_reversed_map_;
92

    
93
    vector<vector<int> > traffic_matrix_;
94

    
95
    CentralityVec v_centrality_vec_;
96
    CentralityPMap v_centrality_pmap_;
97

    
98

    
99
};
100
#endif //GRAPH_PARSER_SUB_COMPONENT_H