From c752952df0dd1d781ec80f25c4b9418bddac1b9e Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 20 Dec 2012 09:40:39 +0100 Subject: [PATCH] Cosmetics. --- mtp_graph.cc | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mtp_graph.cc b/mtp_graph.cc index ea8f91b..5a7da77 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -202,44 +202,44 @@ int MTPGraph::compute_dp_ranks() { // rank of a node is the iteration at which is it removed, and we // set the distance_from_source fields to this value. - Vertex **active = new Vertex *[_nb_vertices]; + Vertex **unreached = new Vertex *[_nb_vertices]; - // All the nodes are active at first + // All the nodes are unreached at first for(int k = 0; k < _nb_vertices; k++) { _vertices[k].distance_from_source = 0; - active[k] = &_vertices[k]; + unreached[k] = &_vertices[k]; } scalar_t rank = 1; - int nb_active = _nb_vertices, pred_nb_active; + int nb_unreached = _nb_vertices, pred_nb_unreached; do { // We set the distance_from_source field of all the vertices with incoming // edges to the current rank value - for(int f = 0; f < nb_active; f++) { - v = active[f]; + for(int f = 0; f < nb_unreached; f++) { + v = unreached[f]; for(e = v->leaving_edges; e; e = e->next_leaving_edge) { e->terminal_vertex->distance_from_source = rank; } } - pred_nb_active = nb_active; - nb_active = 0; + pred_nb_unreached = nb_unreached; + nb_unreached = 0; // We keep all the vertices with incoming nodes - for(int f = 0; f < pred_nb_active; f++) { - v = active[f]; + for(int f = 0; f < pred_nb_unreached; f++) { + v = unreached[f]; if(v->distance_from_source == rank) { - active[nb_active++] = v; + unreached[nb_unreached++] = v; } } rank++; - } while(nb_active < pred_nb_active); + } while(nb_unreached < pred_nb_unreached); - delete[] active; + delete[] unreached; - return nb_active == 0; + return nb_unreached == 0; } ////////////////////////////////////////////////////////////////////// @@ -384,7 +384,7 @@ void MTPGraph::find_shortest_path() { } void MTPGraph::find_best_paths(scalar_t *lengths) { - scalar_t total_length; + scalar_t shortest_path_length; Vertex *v; Edge *e; @@ -408,7 +408,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { find_shortest_path(); - total_length = 0.0; + shortest_path_length = 0.0; // Do we reach the sink? if(_sink->pred_edge_toward_source) { @@ -416,13 +416,13 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { // original edge lengths v = _sink; while(v->pred_edge_toward_source) { - total_length += v->pred_edge_toward_source->length; + shortest_path_length += v->pred_edge_toward_source->length; v = v->pred_edge_toward_source->origin_vertex; } // If that length is negative - if(total_length < 0.0) { + if(shortest_path_length < 0.0) { #ifdef VERBOSE - cerr << __FILE__ << ": Found a path of length " << total_length << endl; + cerr << __FILE__ << ": Found a path of length " << shortest_path_length << endl; #endif // Invert all the edges along the best path v = _sink; @@ -437,7 +437,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { } } - } while(total_length < 0.0); + } while(shortest_path_length < 0.0); // Put back the graph in its original state (i.e. invert edges which // have been inverted in the process) -- 2.39.5