worked on disjkstra and a*

This commit is contained in:
2016-04-10 19:36:51 +02:00
parent d0801606b7
commit e3d245096f
4 changed files with 176 additions and 4 deletions

View File

@@ -49,7 +49,7 @@ public:
// runs until all nodes were evaluated
(void) end;
Log::add("Dijkstra", "calculating dijkstra from " + (std::string)*start + " to ALL OTHER nodes", false);
Log::add("Dijkstra", "calculating dijkstra from " + (std::string)*start + " to " + ((end)?((std::string)*end):"ALL OTHER nodes"), true);
Log::tick();
// cleanup previous runs
@@ -75,10 +75,10 @@ public:
DijkstraNode<T>* dnSrc = toBeProcessedNodes.pop();
// when an end is given, stop when end was reached
if (end != nullptr && dnSrc->element == end) {break;}
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) {break;}
if (maxWeight != 0 && dnSrc->cumWeight > maxWeight) {Log::add("Dijkstra", "reached distance limit"); break;}
// visit (and maybe update) each neighbor of the current element
for (int i = 0; i < acc.getNumNeighbors(*dnSrc->element); ++i) {
@@ -113,8 +113,8 @@ public:
}
Log::add("Dijkstra", "processed " + std::to_string(nodes.size()) + " nodes", false);
Log::tock();
Log::add("Dijkstra", "processed " + std::to_string(nodes.size()) + " nodes");
}