Revision ee0dd796 custompackages/graph-parser/src/common.h

View differences:

custompackages/graph-parser/src/common.h
5 5
#ifndef GRAPH_PARSER_COMMON_H
6 6
#define GRAPH_PARSER_COMMON_H
7 7

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

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

  
10 19
using namespace std;
11 20

  
12
struct Router {
21
class Router { // aka Vertex
22
public:
13 23
    string id;
14 24
    string name;
15 25

  
16 26
    Router() { };
27
    Router(string id, string name) : id(id), name(name) { };
17 28

  
18
    Router(string id, string name) : id(id), name(name) { }
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
   }
19 37
};
20 38

  
21
struct Link {
39
struct Link { // aka Edge
22 40
    double cost;
23 41

  
24 42
    Link() { };
25

  
26 43
    Link(double cost) : cost(cost) { };
27 44
};
28 45

  
......
31 48
        Router, Link> Graph;
32 49
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
33 50
typedef boost::graph_traits<Graph>::vertex_iterator Viter;
51
typedef std::pair<Viter, Viter> Vpair;
34 52

  
35 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> StdVertexIndexMap;
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<StdVertexIndexMap> VertexIndexMap;
61

  
62
typedef map<Edge, size_t> StdEdgeIndexMap;
63
typedef boost::associative_property_map<StdEdgeIndexMap> EdgeIndexMap;
64

  
65

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

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

  
72

  
73
typedef std::vector<double> CentralityVec;
74
typedef boost::iterator_property_map<CentralityVec::iterator, VertexIndexMap> CentralityMap;
36 75

  
37 76
#endif //GRAPH_PARSER_COMMON_H
38 77

  

Also available in: Unified diff