From: Francois Fleuret Date: Tue, 1 Jan 2013 23:04:41 +0000 (+0100) Subject: Cosmetics. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f3de34727021a99f81b2a393653e6ef50af7f50;p=mtp.git Cosmetics. --- diff --git a/mtp_graph.cc b/mtp_graph.cc index 983e3a0..a03f60e 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -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