Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / common.h @ 911d0520

History | View | Annotate | Download (2.36 KB)

1
//
2
// Created by quynh on 12/13/15.
3
//
4

    
5
#ifndef GRAPH_PARSER_COMMON_H
6
#define GRAPH_PARSER_COMMON_H
7

    
8
#include <iostream>
9
#include <cstdlib>
10
#include <exception>
11
#include <string>
12
#include <set>
13
#include <list>
14
#include <vector>
15

    
16
#include <boost/graph/adjacency_list.hpp>
17
#include <boost/graph/iteration_macros.hpp>
18

    
19
using namespace std;
20

    
21
class Router { // aka VertexProperties
22
public:
23
    string id;
24
    string label;
25

    
26
    Router() { };
27
    Router(string i, string l) : id(i), label(l) { };
28

    
29
    bool operator<(const Router& rhs)
30
    {
31
        return id < rhs.id;
32
    }
33

    
34
    bool operator==(const Router& rhs)
35
    {
36
        return id == rhs.id;
37
    }
38

    
39
    bool operator!=(const Router& rhs) {
40
        return id != rhs.id;
41
    }
42
};
43

    
44
struct Link { // aka EdgeProperties
45
    double cost;
46

    
47
    Link() { };
48
    Link(double c) : cost(c) { };
49
};
50

    
51
// List typedefs
52
typedef boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
53
        Router, Link> Graph;
54
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
55
typedef boost::graph_traits<Graph>::vertex_iterator Viter;
56
typedef std::pair<Viter, Viter> Vpair;
57

    
58
typedef boost::graph_traits<Graph>::edge_descriptor Edge;
59
typedef boost::graph_traits<Graph>::edge_iterator Eiter;
60
typedef std::pair<Eiter, Eiter> Epair;
61
typedef boost::graph_traits<Graph>::edges_size_type edges_size_type;
62

    
63
typedef map<Vertex, size_t> VertexIndexStdMap;
64
// This property map is an adaptor that converts any type that is a model of Unique Associative Container such as std::map into a mutable Lvalue Property Map.
65
typedef boost::associative_property_map<VertexIndexStdMap> VertexIndexPMap;
66

    
67
typedef map<Edge, size_t> EdgeIndexStdMap;
68
typedef boost::associative_property_map<EdgeIndexStdMap> EdgeIndexPMap;
69

    
70
typedef std::vector<Vertex> VertexVec;
71
typedef std::vector<Vertex>::iterator VertexVecIter;
72

    
73
typedef std::map<Vertex, int> VertexMap;
74
typedef std::map<Vertex, int>::iterator VertexMapIter;
75

    
76
typedef std::map<std::string, int> NameToIntMap;
77
typedef std::map<std::string, double> NameToDoubleMap;
78

    
79
typedef std::vector<std::string> StringVec;
80
typedef std::vector<std::string>::iterator StringVecIter;
81

    
82
typedef std::set<std::string> StringSet;
83
typedef std::set<std::string>::iterator StringSetIter;
84

    
85
typedef std::vector<double> CentralityVec;
86
typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
87

    
88
#endif //GRAPH_PARSER_COMMON_H
89

    
90