00001
00002
00003
00004
00005
00006 #ifndef ROUTEPLANNINGV2_DIJKSTRA_H_
00007 #define ROUTEPLANNINGV2_DIJKSTRA_H_
00008 #include <queue>
00009 #include <utility>
00010 #include <vector>
00011 #include <string>
00012 #include <functional>
00013 #include "./RoadNetwork.h"
00014 #include "./TransitNetworkExpanded.h"
00015 #include "./TransitNetworkDependent.h"
00016 #include "./Heuristics.h"
00017 #include "./EdgeDependent.h"
00018 #include "./Label.h"
00019 using std::pair;
00020 using std::vector;
00021 using std::priority_queue;
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class Dijkstra
00034 {
00035 public:
00036
00037 Dijkstra(Graph* roadNetwork,
00038 DistanceHeuristic* heuristic);
00039 virtual ~Dijkstra();
00040
00041 virtual void doPrecomputation() = 0;
00042
00043 virtual void atStartOfDijkstra() = 0;
00044
00045 void resetAll();
00046
00047 virtual void resetNode(int nodeId) = 0;
00048 void setHeuristic(DistanceHeuristic* heuristic);
00049
00050 template<bool checkNodes, bool checkEdges, bool rememberEdges,
00051 bool forward, bool toAllNodes>
00052 double computeShortestPath(int startId, int endId);
00053 double computeShortestPath(int startId, int endId,
00054 bool checkNodes, bool checkEdges,
00055 bool rememberEdges, bool forward);
00056
00057
00058
00059
00060
00061
00062
00063 double computeShortestPathToAll(int startId,
00064 bool checkNodes, bool checkEdges,
00065 bool rememberEdges, bool forward);
00066 virtual double computeShortestPath(int startId, int endId,
00067 bool reconstructPath) = 0;
00068
00069 virtual bool nodeAllowed(int nodeId) = 0;
00070
00071 virtual bool edgeAllowed(bool outEdge, int nodeId, int edgeId) = 0;
00072
00073 vector<NodeExpanded> shortestPath;
00074
00075 size_t exploredNodes;
00076 protected:
00077 virtual void reconstructShortestPath(int startId, int endId) = 0;
00078 DistanceHeuristic* heuristic;
00079 vector<double> weights;
00080 vector<double> heuristicValues;
00081 vector<double> timesFromStart;
00082
00083
00084
00085 vector<pair<int, int> > expandedFrom;
00086 vector<bool> expanded;
00087
00088 Graph* _graph;
00089 priority_queue <pair<double, int>,
00090 std::vector<pair<double, int> >,
00091 std::greater<pair<double, int > > > _openNodeQueue;
00092 bool _stopDijkstra;
00093 };
00094
00095 class SimpleDijkstra : public Dijkstra
00096 {
00097 public:
00098 SimpleDijkstra(Graph* roadNetwork,
00099 DistanceHeuristic* heuristic);
00100 SimpleDijkstra();
00101
00102 void doPrecomputation();
00103
00104
00105 void atStartOfDijkstra();
00106
00107
00108 void resetNode(int nodeId);
00109
00110
00111 bool edgeAllowed(bool outEdge, int nodeId, int edgeId);
00112
00113 bool nodeAllowed(int nodeId);
00114 double computeShortestPath(int startId, int endId,
00115 bool reconstructPath);
00116 double computeShortestPath(int startId, int endId,
00117 bool reconstructPath, bool forward);
00118
00119 private:
00120 void reconstructShortestPath(int startId, int endId);
00121 };
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #endif // ROUTEPLANNINGV2_DIJKSTRA_H_