Cosmetics.
authorFrancois Fleuret <francois@fleuret.org>
Tue, 1 Jan 2013 23:04:41 +0000 (00:04 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Tue, 1 Jan 2013 23:04:41 +0000 (00:04 +0100)
mtp_graph.cc

index 983e3a0..a03f60e 100644 (file)
@@ -275,6 +275,7 @@ void MTPGraph::dp_compute_distances() {
 // pred_edge_toward_source.
 
 void MTPGraph::find_shortest_path() {
+  int heap_size;
   Vertex *v, *tv, **last_slot;
   Edge *e;
   scalar_t d;
@@ -284,11 +285,11 @@ void MTPGraph::find_shortest_path() {
     _vertices[k].pred_edge_toward_source = 0;
   }
 
-  int heap_size = _nb_vertices;
+  heap_size = _nb_vertices;
   _source->distance_from_source = 0;
   _source->decrease_distance_in_heap(_heap);
 
-   while(heap_size > 0) {
+   while(heap_size > 1) {
     // Get the closest to the source
     v = _heap[0];
 
@@ -297,7 +298,7 @@ void MTPGraph::find_shortest_path() {
     heap_size--;
     last_slot = _heap + heap_size;
     swap(*_heap, *last_slot); swap((*_heap)->heap_slot, (*last_slot)->heap_slot);
-    _heap[0]->increase_distance_in_heap(_heap, last_slot);
+    (*_heap)->increase_distance_in_heap(_heap, last_slot);
 
     // Now update the neighbors of the node currently closest to the
     // source