Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.59 KB)

1 ee0dd796 Quynh PX Nguyen
//
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 efed924d Quynh PX Nguyen
#include "utility.h"
15 cb770240 Quynh PX Nguyen
#include "graph_manager.h"
16 ee0dd796 Quynh PX Nguyen
17
class SubComponent {
18 efed924d Quynh PX Nguyen
public:
19 20756421 Quynh PX Nguyen
    typedef std::vector<double> CentralityVec;
20
    typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexMap> CentralityMap;
21
22 efed924d Quynh PX Nguyen
    SubComponent();
23 ee0dd796 Quynh PX Nguyen
24 efed924d Quynh PX Nguyen
    // Getter & Setter
25 cb770240 Quynh PX Nguyen
    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 ee0dd796 Quynh PX Nguyen
30 cb770240 Quynh PX Nguyen
    NameToIntMap const& weight_map() const;
31
    NameToIntMap const& weight_reversed_map() const;
32 ee0dd796 Quynh PX Nguyen
33 cb770240 Quynh PX Nguyen
    vector< vector< int > > const& traffic_matrix() const;
34 ee0dd796 Quynh PX Nguyen
35 cb770240 Quynh PX Nguyen
    // 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 20756421 Quynh PX Nguyen
    // BETWEENNESS CENTRALITY
52
    void CalculateBetweennessCentrality();
53
    void initialize_betweenness_centrality();
54
55 cb770240 Quynh PX Nguyen
    // 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 ee0dd796 Quynh PX Nguyen
65
66 cb770240 Quynh PX Nguyen
    // OLD CODE
67 ee0dd796 Quynh PX Nguyen
    void printWeight();
68
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
69
70
    // Betweenness Centrality
71 20756421 Quynh PX Nguyen
72 ee0dd796 Quynh PX Nguyen
    void findBetweennessCentrality();
73
    void printBetweennessCentrality();
74 efed924d Quynh PX Nguyen
75 cb770240 Quynh PX Nguyen
    // NEW CODE
76
    GraphManager gm_;
77
78 efed924d Quynh PX Nguyen
private:
79 cb770240 Quynh PX Nguyen
    StringSet all_vertices_id_;
80
    StringSet art_points_id_;
81
    StringSet non_art_points_id_; // vertices that are not articulation points
82 20756421 Quynh PX Nguyen
    NameToIntMap name_index_map_;
83
84 cb770240 Quynh PX Nguyen
85
    NameToIntMap weight_map_;
86
    NameToIntMap weight_reversed_map_;
87
88
    vector<vector<int> > traffic_matrix_;
89 efed924d Quynh PX Nguyen
90 20756421 Quynh PX Nguyen
    CentralityVec v_centrality_vec_;
91
    CentralityMap v_centrality_map_;
92
93 efed924d Quynh PX Nguyen
94 ee0dd796 Quynh PX Nguyen
};
95
96
97
#endif //GRAPH_PARSER_SUB_COMPONENT_H