PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraphDefinition.h
Go to the documentation of this file.
1 #ifndef GRAPHDEFINITION_H
2 #define GRAPHDEFINITION_H
3 
4 #include <vector>
5 #include <map>
6 #include <queue>
7 #include <string>
8 #include <stdlib.h>
9 #include <iostream>
10 #include <functional>
11 
12 #include "trsp.h"
13 
14 //using namespace std;
15 
16 typedef std::vector<long> LongVector;
17 typedef std::vector<LongVector> VectorOfLongVector;
18 typedef std::pair<int, bool> PIB;
19 typedef std::pair<double, PIB> PDP;
20 typedef std::pair<double, std::vector<int> > PDVI;
21 
22 /*
23 typedef struct edge
24 {
25  int id;
26  int source;
27  int target;
28  double cost;
29  double reverse_cost;
30 } edge_t;
31 
32 typedef struct path_element
33 {
34  int vertex_id;
35  int edge_id;
36  double cost;
37 }path_element_t;
38 */
39 
40 typedef struct{
41  long ed_ind[2];
42  int v_pos[2];
43 } PARENT_PATH;
44 
45 typedef struct Rule{
46  double cost;
47  std::vector<long> precedencelist;
48  Rule(double c, std::vector<long> p) : cost(c), precedencelist(p) { }
49 }Rule;
50 
51 typedef struct{
52  double startCost, endCost;
53 } CostHolder;
54 
55 typedef std::map<long, std::vector<Rule> > RuleTable;
56 
57 
58 
59 class GraphEdgeInfo
60 {
61 public:
62  long m_lEdgeID;
64  short m_sDirection;
65  double m_dCost;
69  //LongVector m_vecConnectedNode;
72 
74  long m_lEndNode;
75 };
76 
77 
78 
79 
80 typedef std::vector<GraphEdgeInfo*> GraphEdgeVector;
81 typedef std::map<long,LongVector> Long2LongVectorMap;
82 typedef std::map<long,long> Long2LongMap;
83 
84 
85 
86 
88 {
89 public:
90  GraphDefinition(void);
91  ~GraphDefinition(void);
92 
93  int my_dijkstra(long start_vertex, long end_vertex,
94  unsigned int edge_count, char** err_msg);
95 
96  int my_dijkstra(edge_t *edges, unsigned int edge_count,
97  long start_vertex, long end_vertex,
98  bool directed, bool has_reverse_cost,
100  char **err_msg);
101 
102  int my_dijkstra(edge_t *edges, unsigned int edge_count,
103  long start_vertex, long end_vertex,
104  bool directed, bool has_reverse_cost,
105  path_element_t **path, int *path_count,
106  char **err_msg,
107  std::vector<PDVI> &ruleList);
108 
109  int my_dijkstra(edge_t *edges, unsigned int edge_count,
110  int start_edge, double start_part,
111  int end_edge, double end_part,
112  bool directed, bool has_reverse_cost,
113  path_element_t **path, int *path_count,
114  char **err_msg,
115  std::vector<PDVI> &ruleList);
116 
117  int multi_dijkstra(edge_t *edges, unsigned int edge_count,
118  std::vector<int> vertices,
119  bool directed, bool has_reverse_cost,
120  path_element_t **path, int *path_count,
121  char **err_msg,
122  std::vector<PDVI> &ruleList);
123 
124  bool construct_graph(edge_t *edges, int edge_count,
125  bool has_reverse_cost, bool directed);
126 
127 
128 private:
129  double construct_path(long ed_id, int v_pos);
130  void explore(long cur_node, GraphEdgeInfo& cur_edge, bool isStart, LongVector &vecIndex, std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > &que);
131  double getRestrictionCost(long cur_node, GraphEdgeInfo& new_edge, bool isStart);
132  bool addEdge(edge edgeIn);
133  bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
134  bool get_single_cost(double total_cost, path_element_t **path, int *path_count);
135  void init();
136  void deleteall();
137 
138 private:
146  double m_dStartpart;
147  double m_dEndPart;
150 
151  std::vector <path_element_t> m_vecPath;
157 };
158 
159 #endif
Rule(double c, std::vector< long > p)
std::vector< LongVector > VectorOfLongVector
std::pair< double, std::vector< int > > PDVI
std::pair< int, bool > PIB
bool get_single_cost(double total_cost, path_element_t **path, int *path_count)
std::vector< GraphEdgeInfo > GraphEdgeVector
int path_count
Definition: BDATester.cpp:51
std::map< size_t, LongVector > Long2LongVectorMap
GraphEdgeVector m_vecEdgeVector
std::map< long, long > Long2LongMap
std::map< long, std::vector< Rule > > RuleTable
bool addEdge(edge edgeIn)
std::map< size_t, size_t > Long2LongMap
std::vector< path_element_t > m_vecPath
double m_dReverseCost
RuleTable m_ruleTable
bool m_bIsLeadingRestrictedEdge
Long2LongMap m_mapEdgeId2Index
Long2LongVectorMap m_mapNodeId2Edge
int my_dijkstra(long start_vertex, long end_vertex, unsigned int edge_count, char **err_msg)
struct Rule Rule
std::map< long, LongVector > Long2LongVectorMap
std::vector< long > precedencelist
double getRestrictionCost(long cur_node, GraphEdgeInfo &new_edge, bool isStart)
bool construct_graph(edge_t *edges, int edge_count, bool has_reverse_cost, bool directed)
bool connectEdge(GraphEdgeInfo &firstEdge, GraphEdgeInfo &secondEdge, bool bIsStartNodeSame)
int multi_dijkstra(edge_t *edges, unsigned int edge_count, std::vector< int > vertices, bool directed, bool has_reverse_cost, path_element_t **path, int *path_count, char **err_msg, std::vector< PDVI > &ruleList)
std::vector< long > LongVector
int edge_count
Definition: BDATester.cpp:47
edge_astar_t * edges
Definition: BDATester.cpp:46
double construct_path(long ed_id, int v_pos)
std::vector< GraphEdgeInfo * > GraphEdgeVector
LongVector m_vecEndConnedtedEdge
std::vector< size_t > LongVector
PARENT_PATH * parent
std::pair< double, PIB > PDP
path_element_t * path
Definition: BDATester.cpp:49
CostHolder * m_dCost
std::vector< LongVector > VectorOfLongVector
void explore(long cur_node, GraphEdgeInfo &cur_edge, bool isStart, LongVector &vecIndex, std::priority_queue< PDP, std::vector< PDP >, std::greater< PDP > > &que)
char * err_msg
Definition: BDATester.cpp:50
double cost
double startCost
VectorOfLongVector m_vecRestrictedEdge
LongVector m_vecStartConnectedEdge