Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / common.h @ 4ca27bae

History | View | Annotate | Download (2.36 KB)

1 04a9ef10 Quynh PX Nguyen
//
2
// Created by quynh on 12/13/15.
3
//
4
5
#ifndef GRAPH_PARSER_COMMON_H
6
#define GRAPH_PARSER_COMMON_H
7
8 ee0dd796 Quynh PX Nguyen
#include <iostream>
9
#include <cstdlib>
10
#include <exception>
11
#include <string>
12
#include <set>
13
#include <list>
14
#include <vector>
15
16 c6961065 Quynh PX Nguyen
#include <boost/graph/adjacency_list.hpp>
17 ee0dd796 Quynh PX Nguyen
#include <boost/graph/iteration_macros.hpp>
18 c6961065 Quynh PX Nguyen
19 04a9ef10 Quynh PX Nguyen
using namespace std;
20
21 efed924d Quynh PX Nguyen
class Router { // aka VertexProperties
22 ee0dd796 Quynh PX Nguyen
public:
23 6a12e353 Quynh PX Nguyen
    string id;
24 efed924d Quynh PX Nguyen
    string label;
25 6a12e353 Quynh PX Nguyen
26
    Router() { };
27 efed924d Quynh PX Nguyen
    Router(string i, string l) : id(i), label(l) { };
28 6a12e353 Quynh PX Nguyen
29 ee0dd796 Quynh PX Nguyen
    bool operator<(const Router& rhs)
30
    {
31 e263e3c7 Quynh PX Nguyen
        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 ee0dd796 Quynh PX Nguyen
    }
42 6a12e353 Quynh PX Nguyen
};
43
44 efed924d Quynh PX Nguyen
struct Link { // aka EdgeProperties
45 6a12e353 Quynh PX Nguyen
    double cost;
46
47
    Link() { };
48 efed924d Quynh PX Nguyen
    Link(double c) : cost(c) { };
49 6a12e353 Quynh PX Nguyen
};
50
51 04a9ef10 Quynh PX Nguyen
// List typedefs
52 6a12e353 Quynh PX Nguyen
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 ee0dd796 Quynh PX Nguyen
typedef std::pair<Viter, Viter> Vpair;
57 6a12e353 Quynh PX Nguyen
58
typedef boost::graph_traits<Graph>::edge_descriptor Edge;
59 ee0dd796 Quynh PX Nguyen
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 cb770240 Quynh PX Nguyen
typedef map<Vertex, size_t> VertexIndexStdMap;
64 ee0dd796 Quynh PX Nguyen
// 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 437fd680 Quynh PX Nguyen
typedef boost::associative_property_map<VertexIndexStdMap> VertexIndexPMap;
66 ee0dd796 Quynh PX Nguyen
67 cb770240 Quynh PX Nguyen
typedef map<Edge, size_t> EdgeIndexStdMap;
68 437fd680 Quynh PX Nguyen
typedef boost::associative_property_map<EdgeIndexStdMap> EdgeIndexPMap;
69 ee0dd796 Quynh PX Nguyen
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 cb770240 Quynh PX Nguyen
typedef std::map<std::string, int> NameToIntMap;
77 437fd680 Quynh PX Nguyen
typedef std::map<std::string, double> NameToDoubleMap;
78 cb770240 Quynh PX Nguyen
79 efed924d Quynh PX Nguyen
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 ee0dd796 Quynh PX Nguyen
85
typedef std::vector<double> CentralityVec;
86 437fd680 Quynh PX Nguyen
typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexPMap> CentralityPMap;
87 6a12e353 Quynh PX Nguyen
88
#endif //GRAPH_PARSER_COMMON_H
89