-
- 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);
-
- delete[] front;
- delete[] new_front;
-}
-
-void Graph::find_best_paths() {
- scalar_t total_length;
-
- initialize_work_lengths();
-
- do {
-#ifdef VERBOSE
- print();
-#endif
-
- total_length = 0.0;
- find_shortest_path();
- update_work_length();
-
- // Do we reach the sink?
- if(sink->pred_edge) {
-
-#ifdef VERBOSE
- cout << "VERBOSE there is a path reaching the sink" << endl;
-#endif
-
- // If yes, compute the length of the best path
- for(Vertex *v = sink; v->pred_edge; v = v->pred_vertex) {
- total_length += v->pred_edge->length;
- }
-
-#ifdef VERBOSE
- cout << "VERBOSE total_length " << total_length << endl;
-#endif
-
- // If that length is negative
- if(total_length < 0.0) {
- // Invert all the edges along the best path
- for(Vertex *v = sink; v->pred_edge; v = v->pred_vertex) {
- Edge *e = v->pred_edge;
- e->terminal_vertex = v->pred_vertex;
- e->occupied = 1 - e->occupied;
- e->length = - e->length;
- e->work_length = - e->work_length;
- v->pred_vertex->del_edge(e);
- v->add_edge(e);
- }
- }
- }
- } while(total_length < 0.0);
-}
-
-//////////////////////////////////////////////////////////////////////
-
-int main(int argc, char **argv) {
-
- if(argc < 2) {
- cerr << argv[0] << " <graph file>" << endl;
- exit(EXIT_FAILURE);