Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / sub_component.h @ 6575aa2e

History | View | Annotate | Download (3.18 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 162e1bda Quynh PX Nguyen
#include "centrality.h"
14 ee0dd796 Quynh PX Nguyen
#include "common.h"
15 efed924d Quynh PX Nguyen
#include "utility.h"
16 cb770240 Quynh PX Nguyen
#include "graph_manager.h"
17 ee0dd796 Quynh PX Nguyen
18
class SubComponent {
19 efed924d Quynh PX Nguyen
public:
20 20756421 Quynh PX Nguyen
    typedef std::vector<double> CentralityVec;
21 437fd680 Quynh PX Nguyen
    typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
22 20756421 Quynh PX Nguyen
23 d5b7a27f Quynh PX Nguyen
    SubComponent(bool weighted_graph = false);
24 ee0dd796 Quynh PX Nguyen
25 efed924d Quynh PX Nguyen
    // Getter & Setter
26 cb770240 Quynh PX Nguyen
    GraphManager const& gm() const;
27
    StringSet const& all_vertices_id() const;
28
    StringSet const& art_points_id() const;
29
    StringSet const& non_art_points_id() const;
30 ee0dd796 Quynh PX Nguyen
31 cb770240 Quynh PX Nguyen
    NameToIntMap const& weight_map() const;
32
    NameToIntMap const& weight_reversed_map() const;
33 ee0dd796 Quynh PX Nguyen
34 162e1bda Quynh PX Nguyen
    std::map< std::pair<string, string>, int > const& traffic_matrix() const;
35 ee0dd796 Quynh PX Nguyen
36 437fd680 Quynh PX Nguyen
    CentralityVec const& v_centrality_vec() const;
37
38 cb770240 Quynh PX Nguyen
    // CREATE SUB-COMPONENT
39
    void AddEdge(Router r1, Router r2, Link l);
40
    void FinalizeSubComponent(StringSet all_art_points_id);
41
42
    // LINK WEIGHT CALCULATION
43
    void initialize_weight();
44
    int get_weight_map(string name);
45
    int get_weight_reversed_map(string name);
46
    void update_weight_map(string name, int value);
47 162e1bda Quynh PX Nguyen
    void update_weight_reversed_map(string name, int value);
48
    void calculate_weight_reversed(int V);
49 cb770240 Quynh PX Nguyen
50
    // TRAFFIC MATRIX CALCULATION
51
    void CalculateTrafficMatrix();
52
    void initialize_traffic_matrix();
53
    int get_traffic_matrix(string name_1, string name_2);
54
    void update_traffic_matrix(string name_1, string name_2, int value);
55
56 20756421 Quynh PX Nguyen
    // BETWEENNESS CENTRALITY
57 162e1bda Quynh PX Nguyen
    void CalculateBetweennessCentralityHeuristic();
58 20756421 Quynh PX Nguyen
    void initialize_betweenness_centrality();
59 437fd680 Quynh PX Nguyen
    double get_betweenness_centrality(string name);
60
    double get_betweenness_centrality(Vertex v);
61 20756421 Quynh PX Nguyen
62 cb770240 Quynh PX Nguyen
    // HELPERS
63
    int num_of_vertices();
64
    int index_of_vertex_id(string vertex_id);
65
    bool vertex_exists(string name);
66
    string first_vertex_id_with_unknown_weight();
67
68
    // HELPERS FOR OUTPUTTING RESULT
69 437fd680 Quynh PX Nguyen
    void print();
70
    void print_traffic_matrix();
71 162e1bda Quynh PX Nguyen
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
72 ee0dd796 Quynh PX Nguyen
73
74 cb770240 Quynh PX Nguyen
    // OLD CODE
75 ee0dd796 Quynh PX Nguyen
    void printWeight();
76
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
77
78
    // Betweenness Centrality
79 20756421 Quynh PX Nguyen
80 ee0dd796 Quynh PX Nguyen
    void findBetweennessCentrality();
81
    void printBetweennessCentrality();
82 efed924d Quynh PX Nguyen
83 cb770240 Quynh PX Nguyen
    // NEW CODE
84
    GraphManager gm_;
85
86 efed924d Quynh PX Nguyen
private:
87 cb770240 Quynh PX Nguyen
    StringSet all_vertices_id_;
88
    StringSet art_points_id_;
89
    StringSet non_art_points_id_; // vertices that are not articulation points
90 437fd680 Quynh PX Nguyen
    NameToIntMap name_index_pmap_;
91 20756421 Quynh PX Nguyen
92 cb770240 Quynh PX Nguyen
    NameToIntMap weight_map_;
93
    NameToIntMap weight_reversed_map_;
94
95 162e1bda Quynh PX Nguyen
    typedef std::map< std::pair<string, string>, int> TrafficMatrixStdMap;
96
    typedef boost::associative_property_map<TrafficMatrixStdMap> TrafficMatrixPMap;
97
    TrafficMatrixStdMap traffic_matrix_;
98
    TrafficMatrixPMap traffic_matrix_pmap_;
99
100
    // vector<vector<int> > traffic_matrix_;
101 efed924d Quynh PX Nguyen
102 20756421 Quynh PX Nguyen
    CentralityVec v_centrality_vec_;
103 437fd680 Quynh PX Nguyen
    CentralityPMap v_centrality_pmap_;
104 20756421 Quynh PX Nguyen
105 efed924d Quynh PX Nguyen
106 ee0dd796 Quynh PX Nguyen
};
107
#endif //GRAPH_PARSER_SUB_COMPONENT_H