// pred_edge_toward_source.
void MTPGraph::find_shortest_path() {
+ int heap_size;
Vertex *v, *tv, **last_slot;
Edge *e;
scalar_t d;
_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];
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