qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
dijkstra.h
Go to the documentation of this file.
1#ifndef Q_HEX_WALKER_DIJKSTRA_H
2#define Q_HEX_WALKER_DIJKSTRA_H
3
4class Dijkstra {
5public:
6 // Найти кратчайший путь между двумя H3-индексами
7 std::vector<H3Index> findShortestPath(H3Index start, H3Index end);
8
9private:
10 // Хеш-функция для H3Index
11 struct H3IndexHash {
12 std::size_t operator()(const H3Index &index) const { return std::hash<uint64_t>()(index); }
13 };
14 // Структура для узла в алгоритме Дейкстры
15 struct Node {
16 H3Index cell;
17 double distance;
18
19 bool operator>(const Node &other) const { return distance > other.distance; }
20 };
21
22 // Получить соседей H3-ячейки
23 static std::vector<H3Index> getNeighbors(H3Index cell);
24 // Вычислить расстояние между двумя H3-ячейками
25 static double getDistanceBetweenCells(H3Index cell1, H3Index cell2);
26 // Восстановить путь из карты предшественников
27 static std::vector<H3Index> reconstructPath(const std::unordered_map<H3Index, H3Index, H3IndexHash> &previous,
28 H3Index start, H3Index end);
29};
30
31#endif // Q_HEX_WALKER_DIJKSTRA_H
std::vector< H3Index > findShortestPath(H3Index start, H3Index end)
Definition dijkstra.cpp:5
static double getDistanceBetweenCells(H3Index cell1, H3Index cell2)
Definition dijkstra.cpp:104
static std::vector< H3Index > reconstructPath(const std::unordered_map< H3Index, H3Index, H3IndexHash > &previous, H3Index start, H3Index end)
Definition dijkstra.cpp:118
static std::vector< H3Index > getNeighbors(H3Index cell)
Definition dijkstra.cpp:79
std::size_t operator()(const H3Index &index) const
Definition dijkstra.h:12
H3Index cell
Definition dijkstra.h:16
bool operator>(const Node &other) const
Definition dijkstra.h:19
double distance
Definition dijkstra.h:17