- tmp_front = _new_front;
- _new_front = _front;
- _front = tmp_front;
-
- tmp_front_size = _new_front_size;
- _new_front_size = _front_size;
- _front_size = tmp_front_size;
- } while(_front_size > 0);
+ v = _heap[0];
+ _heap_size--;
+ Vertex **a = _heap, **b = _heap + _heap_size;
+ swap(*a, *b); swap((*a)->heap_position, (*b)->heap_position);
+ increase_distance_in_heap(_heap[0]);
+
+ for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
+ d = v->distance_from_source + e->positivized_length;
+ tv = e->terminal_vertex;
+ if(d < tv->distance_from_source) {
+ ASSERT(tv->heap_position - _heap < _heap_size);
+ tv->distance_from_source = d;
+ tv->pred_edge_toward_source = e;
+ decrease_distance_in_heap(tv);
+ }
+#ifdef DEBUG
+ for(int k = 0; k < _heap_size; k++) {
+ if(_heap[0]->distance_from_source > _heap[k]->distance_from_source) abort();
+ }
+#endif
+ }
+ } while(_heap_size > 0);
+
+#ifdef DEBUG
+ for(int k = 0; k < _nb_vertices; k++) {
+ v = &_vertices[k];
+ for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
+ d = v->distance_from_source + e->positivized_length;
+ tv = e->terminal_vertex;
+ if(d < tv->distance_from_source) abort();
+ }
+ }
+#endif
+ cout << "DONE!" << endl;