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