summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2016-10-06 19:44:29 +0200
committerPaul Jungeblut <paul.jungeblut@gmail.com>2016-10-06 19:44:29 +0200
commit7cf8f4e10ac917ed8b900e43e294e26200329ee8 (patch)
treee8d625e0277df3ec1c7aa12efa79262358a4eded
parentfd6f3c1b886b8baf2fb02789717f021abe4a3fe0 (diff)
Saving space in Dijkstra.
-rw-r--r--graph/dijkstra.cpp12
-rw-r--r--tcr.pdfbin264693 -> 264546 bytes
2 files changed, 3 insertions, 9 deletions
diff --git a/graph/dijkstra.cpp b/graph/dijkstra.cpp
index 1fb5f53..52cb57e 100644
--- a/graph/dijkstra.cpp
+++ b/graph/dijkstra.cpp
@@ -2,22 +2,16 @@
void dijkstra(int start) {
priority_queue<ii, vector<ii>, greater<ii> > pq;
vector<int> dist(NUM_VERTICES, INF), parent(NUM_VERTICES, -1);
-
- dist[start] = 0;
- pq.push(ii(0, start));
+ dist[start] = 0; pq.push(ii(0, start));
while (!pq.empty()) {
ii front = pq.top(); pq.pop();
int curNode = front.second, curDist = front.first;
-
- if (curDist > dist[curNode]) continue;
+ if (curDist > dist[curNode]) continue; // WICHTIG!
for (auto n : adjlist[curNode]) {
int nextNode = n.first, nextDist = curDist + n.second;
if (nextDist < dist[nextNode]) {
dist[nextNode] = nextDist; parent[nextNode] = curNode;
pq.push(ii(nextDist, nextNode));
- }
- }
- }
-}
+}}}}
diff --git a/tcr.pdf b/tcr.pdf
index 357923b..8131aa0 100644
--- a/tcr.pdf
+++ b/tcr.pdf
Binary files differ