From 1f3de34727021a99f81b2a393653e6ef50af7f50 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Wed, 2 Jan 2013 00:04:41 +0100 Subject: [PATCH] Cosmetics. --- mtp_graph.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 -- 2.20.1