Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / sub_component.h @ 20756421

History | View | Annotate | Download (2.59 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, VertexIndexMap> CentralityMap;
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
    // CREATE SUB-COMPONENT
36
    void AddEdge(Router r1, Router r2, Link l);
37
    void FinalizeSubComponent(StringSet all_art_points_id);
38

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

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

    
51
    // BETWEENNESS CENTRALITY
52
    void CalculateBetweennessCentrality();
53
    void initialize_betweenness_centrality();
54

    
55
    // HELPERS
56
    int num_of_vertices();
57
    int index_of_vertex_id(string vertex_id);
58
    bool vertex_exists(string name);
59
    string first_vertex_id_with_unknown_weight();
60

    
61
    // HELPERS FOR OUTPUTTING RESULT
62
    void print_traffic_matrix();
63
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
64

    
65

    
66
    // OLD CODE
67
    void printWeight();
68
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
69

    
70
    // Betweenness Centrality
71

    
72
    void findBetweennessCentrality();
73
    void printBetweennessCentrality();
74

    
75
    // NEW CODE
76
    GraphManager gm_;
77

    
78
private:
79
    StringSet all_vertices_id_;
80
    StringSet art_points_id_;
81
    StringSet non_art_points_id_; // vertices that are not articulation points
82
    NameToIntMap name_index_map_;
83

    
84

    
85
    NameToIntMap weight_map_;
86
    NameToIntMap weight_reversed_map_;
87

    
88
    vector<vector<int> > traffic_matrix_;
89

    
90
    CentralityVec v_centrality_vec_;
91
    CentralityMap v_centrality_map_;
92

    
93

    
94
};
95

    
96

    
97
#endif //GRAPH_PARSER_SUB_COMPONENT_H