Revision cb770240 custompackages/graph-parser/src/sub_component.h

View differences:

custompackages/graph-parser/src/sub_component.h
12 12
#include <boost/graph/copy.hpp>
13 13
#include "common.h"
14 14
#include "utility.h"
15
#include "graph_manager.h"
15 16

  
16 17
class SubComponent {
17 18
public:
18 19
    SubComponent();
19
    SubComponent(const StringSet art_points, const Graph sub_graph);
20 20

  
21 21
    // Getter & Setter
22
    StringSet art_points() const;
23
    void set_art_points(StringSet& art_points);
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;
24 26

  
25
    // Manipulating subGraph
26
    int num_vertices();
27
    void AddEdge(Router r1, Router r2, Link l);
28
    bool vertex_existed(string s);
29
    const Vertex& get_vertex_from_id(string s);
30
    Graph const& sub_graph() const;
27
    NameToIntMap const& weight_map() const;
28
    NameToIntMap const& weight_reversed_map() const;
31 29

  
32
    // Output to console
33
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
30
    vector< vector< int > > const& traffic_matrix() const;
34 31

  
35
    void init();
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);
36 57

  
37 58

  
38
    // calculate Link Weight
39
    void _initialize_weight();
40
    void setWeight(Vertex art_point, int value);
41
    int getWeight(Vertex art_point);
42
    int getReversedWeight(Vertex art_point);
59
    // OLD CODE
43 60
    void printWeight();
44 61
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
45 62

  
46 63
    // Traffic Matrix
47
    int getTrafficMatrix(Vertex v_1, Vertex v_2);
48
    void _initializeTrafficMatrix();
49
    int _indexOfVertex(Vertex v);
50
    void _setTrafficMatrix(Vertex v_1, Vertex v_2, int value);
51 64
    void _computeTrafficMatrix();
52 65

  
53 66
    // Betweenness Centrality
......
55 68
    void findBetweennessCentrality();
56 69
    void printBetweennessCentrality();
57 70

  
71
    // NEW CODE
72
    GraphManager gm_;
73

  
58 74
private:
59
    StringSet art_points_;
60
    StringVec normal_vertices; // vertices that are not articulation points
61
    // std::vector<Vertex*> normal_vertices;
62
    // TODO: should this one be public?
63
    std::map<std::string, Vertex> name_vertex_map_;
64
    Graph sub_graph_;
65
    VertexMap weightMap;
66
    VertexMap weightReversedMap;
67

  
68
    StdVertexIndexMap v_index_std_map;
69
    VertexIndexMap v_index_map;
70
    vector<vector<int> > trafficMatrix;
71

  
72
    CentralityVec v_centrality_vec;
73
    CentralityMap v_centrality_map;
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_;
74 84

  
75 85
    // Traffic Matrix
76 86

  

Also available in: Unified diff