#ifndef DIJKSTRANODE_H #define DIJKSTRANODE_H /** * wrapper around a user data structure * adds additional fields needed for dijkstra calculation */ template struct DijkstraNode { /** pos infinity */ static constexpr float INF = +99999999; /** the user-element this node describes */ const T* element; /** the previous dijkstra node (navigation path) */ DijkstraNode* previous; /** the weight from the start up to this element */ float cumWeight; /** ctor */ DijkstraNode(const T* element) : element(element), previous(), cumWeight(INF) {;} // /** equal? (bi-dir) */ // bool operator == (const DijkstraNode& other) const { // return element == other.element; // } }; /** * data structure describing the connection between two nodes. * NOTE: only used to track already processed connections! */ template struct DijkstraEdge { /** the edge's source */ const DijkstraNode* src; /** the edge's destination */ const DijkstraNode* dst; /** ctor */ DijkstraEdge(const DijkstraNode* src, const DijkstraNode* dst) : src(src), dst(dst) {;} /** equal? (bi-directional! edge direction does NOT matter) */ bool operator == (const DijkstraEdge& other) const { return ((dst == other.dst) && (src == other.src)) || ((src == other.dst) && (dst == other.src)); } }; /** allows adding DijkstraEdge to hash-maps */ namespace std { template struct hash>{ size_t operator()(const DijkstraEdge& e) const { return hash()( (size_t)e.src^(size_t)e.dst); } }; } #endif // DIJKSTRANODE_H