Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.41 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
    SubComponent();
20

    
21
    // Getter & Setter
22
    GraphManager const& gm() const;
23
    StringSet const& all_vertices_id() const;
24
    StringSet const& art_points_id() const;
25
    StringSet const& non_art_points_id() const;
26

    
27
    NameToIntMap const& weight_map() const;
28
    NameToIntMap const& weight_reversed_map() const;
29

    
30
    vector< vector< int > > const& traffic_matrix() const;
31

    
32
    // CREATE SUB-COMPONENT
33
    void AddEdge(Router r1, Router r2, Link l);
34
    void FinalizeSubComponent(StringSet all_art_points_id);
35

    
36
    // LINK WEIGHT CALCULATION
37
    void initialize_weight();
38
    int get_weight_map(string name);
39
    int get_weight_reversed_map(string name);
40
    void update_weight_map(string name, int value);
41

    
42
    // TRAFFIC MATRIX CALCULATION
43
    void CalculateTrafficMatrix();
44
    void initialize_traffic_matrix();
45
    int get_traffic_matrix(string name_1, string name_2);
46
    void update_traffic_matrix(string name_1, string name_2, int value);
47

    
48
    // HELPERS
49
    int num_of_vertices();
50
    int index_of_vertex_id(string vertex_id);
51
    bool vertex_exists(string name);
52
    string first_vertex_id_with_unknown_weight();
53

    
54
    // HELPERS FOR OUTPUTTING RESULT
55
    void print_traffic_matrix();
56
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
57

    
58

    
59
    // OLD CODE
60
    void printWeight();
61
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
62

    
63
    // Traffic Matrix
64
    void _computeTrafficMatrix();
65

    
66
    // Betweenness Centrality
67
    void _initializeBetweennessCentrality();
68
    void findBetweennessCentrality();
69
    void printBetweennessCentrality();
70

    
71
    // NEW CODE
72
    GraphManager gm_;
73

    
74
private:
75
    StringSet all_vertices_id_;
76
    StringSet art_points_id_;
77
    StringSet non_art_points_id_; // vertices that are not articulation points
78

    
79
    NameToIntMap weight_map_;
80
    NameToIntMap weight_reversed_map_;
81

    
82
    NameToIntMap name_index_map_;
83
    vector<vector<int> > traffic_matrix_;
84

    
85
    // Traffic Matrix
86

    
87
    // Betweenness Centrality
88
};
89

    
90

    
91
#endif //GRAPH_PARSER_SUB_COMPONENT_H