root / custompackages / graph-parser / src / sub_component.h @ 911d0520
History | View | Annotate | Download (3.18 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 "centrality.h" |
14 |
#include "common.h" |
15 |
#include "utility.h" |
16 |
#include "graph_manager.h" |
17 |
|
18 |
class SubComponent { |
19 |
public:
|
20 |
typedef std::vector<double> CentralityVec; |
21 |
typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
|
22 |
|
23 |
SubComponent(bool weighted_graph = false); |
24 |
|
25 |
// Getter & Setter
|
26 |
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 |
|
31 |
NameToIntMap const& weight_map() const; |
32 |
NameToIntMap const& weight_reversed_map() const; |
33 |
|
34 |
std::map< std::pair<string, string>, int > const& traffic_matrix() const; |
35 |
|
36 |
CentralityVec const& v_centrality_vec() const; |
37 |
|
38 |
// 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 |
void update_weight_reversed_map(string name, int value); |
48 |
void calculate_weight_reversed(int V); |
49 |
|
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 |
// BETWEENNESS CENTRALITY
|
57 |
void CalculateBetweennessCentralityHeuristic();
|
58 |
void initialize_betweenness_centrality();
|
59 |
double get_betweenness_centrality(string name);
|
60 |
double get_betweenness_centrality(Vertex v);
|
61 |
|
62 |
// 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 |
void print();
|
70 |
void print_traffic_matrix();
|
71 |
friend std::ostream& operator<<(std::ostream& os, const SubComponent& sc);
|
72 |
|
73 |
|
74 |
// OLD CODE
|
75 |
void printWeight();
|
76 |
void _find_vertices_with_unknown_weight(VertexVec& unknown_weight_vertices);
|
77 |
|
78 |
// Betweenness Centrality
|
79 |
|
80 |
void findBetweennessCentrality();
|
81 |
void printBetweennessCentrality();
|
82 |
|
83 |
// NEW CODE
|
84 |
GraphManager gm_; |
85 |
|
86 |
private:
|
87 |
StringSet all_vertices_id_; |
88 |
StringSet art_points_id_; |
89 |
StringSet non_art_points_id_; // vertices that are not articulation points
|
90 |
NameToIntMap name_index_pmap_; |
91 |
|
92 |
NameToIntMap weight_map_; |
93 |
NameToIntMap weight_reversed_map_; |
94 |
|
95 |
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 |
|
102 |
CentralityVec v_centrality_vec_; |
103 |
CentralityPMap v_centrality_pmap_; |
104 |
|
105 |
|
106 |
}; |
107 |
#endif //GRAPH_PARSER_SUB_COMPONENT_H |