Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / common.h @ 437fd680

History | View | Annotate | Download (2.28 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
   bool operator==(const Router& rhs)
34
   {
35
       return id == rhs.id;
36
   }
37
};
38

    
39
struct Link { // aka EdgeProperties
40
    double cost;
41

    
42
    Link() { };
43
    Link(double c) : cost(c) { };
44
};
45

    
46
// List typedefs
47
typedef boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
48
        Router, Link> Graph;
49
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
50
typedef boost::graph_traits<Graph>::vertex_iterator Viter;
51
typedef std::pair<Viter, Viter> Vpair;
52

    
53
typedef boost::graph_traits<Graph>::edge_descriptor Edge;
54
typedef boost::graph_traits<Graph>::edge_iterator Eiter;
55
typedef std::pair<Eiter, Eiter> Epair;
56
typedef boost::graph_traits<Graph>::edges_size_type edges_size_type;
57

    
58
typedef map<Vertex, size_t> VertexIndexStdMap;
59
// 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.
60
typedef boost::associative_property_map<VertexIndexStdMap> VertexIndexPMap;
61

    
62
typedef map<Edge, size_t> EdgeIndexStdMap;
63
typedef boost::associative_property_map<EdgeIndexStdMap> EdgeIndexPMap;
64

    
65
typedef std::vector<Vertex> VertexVec;
66
typedef std::vector<Vertex>::iterator VertexVecIter;
67

    
68
typedef std::map<Vertex, int> VertexMap;
69
typedef std::map<Vertex, int>::iterator VertexMapIter;
70

    
71
typedef std::map<std::string, int> NameToIntMap;
72
typedef std::map<std::string, double> NameToDoubleMap;
73

    
74
typedef std::vector<std::string> StringVec;
75
typedef std::vector<std::string>::iterator StringVecIter;
76

    
77
typedef std::set<std::string> StringSet;
78
typedef std::set<std::string>::iterator StringSetIter;
79

    
80
typedef std::vector<double> CentralityVec;
81
typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
82

    
83
#endif //GRAPH_PARSER_COMMON_H
84

    
85