added new helper methods
worked on gridWalker v3
This commit is contained in:
@@ -30,11 +30,16 @@ public:
|
||||
}
|
||||
|
||||
/** get the dijkstra-pendant for the given user-node. null if none matches */
|
||||
const inline DijkstraNode<T>* getNode(const T& userNode) const {
|
||||
inline const DijkstraNode<T>* getNode(const T& userNode) const {
|
||||
auto it = nodes.find(&userNode);
|
||||
return (unlikely(it == nodes.end())) ? (nullptr) : (it->second);
|
||||
}
|
||||
|
||||
/** get all constructed dijkstra-nodes and their original pendant */
|
||||
inline const std::unordered_map<const T*, DijkstraNode<T>*>& getNodes() const {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/** calculate all shortest paths from ANY node to the given destination */
|
||||
template <typename Access> void build(const T* end, const Access& acc) {
|
||||
build(end, nullptr, acc, NAN);
|
||||
@@ -80,7 +85,7 @@ public:
|
||||
if (end != nullptr && dnSrc->element == end) {Log::add("Dijkstra", "reached target node"); break;}
|
||||
|
||||
// when a maximum weight is given, stop when current cum-dist > maxWeight
|
||||
if (maxWeight != 0 && dnSrc->cumWeight > maxWeight) {Log::add("Dijkstra", "reached distance limit"); break;}
|
||||
if (maxWeight != 0 && dnSrc->cumWeight > maxWeight) {Log::add("Dijkstra", "reached weight limit: " + std::to_string(maxWeight)); break;}
|
||||
|
||||
// visit (and maybe update) each neighbor of the current element
|
||||
for (int i = 0; i < acc.getNumNeighbors(*dnSrc->element); ++i) {
|
||||
|
||||
Reference in New Issue
Block a user