Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.19 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

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

    
21
    // Getter & Setter
22
    StringSet art_points() const;
23
    void set_art_points(StringSet& art_points);
24

    
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;
31

    
32
    // Output to console
33
    friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
34

    
35
    void init();
36

    
37

    
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);
43
    void printWeight();
44
    void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
45

    
46
    // 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
    void _computeTrafficMatrix();
52

    
53
    // Betweenness Centrality
54
    void _initializeBetweennessCentrality();
55
    void findBetweennessCentrality();
56
    void printBetweennessCentrality();
57

    
58
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;
74

    
75
    // Traffic Matrix
76

    
77
    // Betweenness Centrality
78
};
79

    
80

    
81
#endif //GRAPH_PARSER_SUB_COMPONENT_H