From 9d423de49725cbb204657653340f8585a0557f55 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sun, 30 Dec 2012 00:52:00 +0100 Subject: [PATCH] Cosmetics. --- mtp_graph.cc | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/mtp_graph.cc b/mtp_graph.cc index 48de3ca..c17917e 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -133,17 +133,6 @@ void Vertex::increase_distance_in_heap(Vertex **heap, Vertex **heap_bottom) { ////////////////////////////////////////////////////////////////////// -static int compare_vertices_on_distance(const void *v1, const void *v2) { - scalar_t delta = - (*((Vertex **) v1))->distance_from_source - - (*((Vertex **) v2))->distance_from_source; - if(delta < 0) return -1; - else if(delta > 0) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////// - MTPGraph::MTPGraph(int nb_vertices, int nb_edges, int *vertex_from, int *vertex_to, int source, int sink) { @@ -430,14 +419,23 @@ int MTPGraph::retrieve_one_path(Edge *e, Path *path) { ////////////////////////////////////////////////////////////////////// +static int compare_vertices_on_distance(const void *v1, const void *v2) { + scalar_t delta = + (*((Vertex **) v1))->distance_from_source - + (*((Vertex **) v2))->distance_from_source; + if(delta < 0) return -1; + else if(delta > 0) return 1; + else return 0; +} + void MTPGraph::compute_dp_ordering() { Vertex *v; Edge *e; - int tv; + int ntv; - // This procedure computes for each node the longest link from the - // source, and abort if the graph is not a DAG, and order the node - // in _dp_order according to that value. + // This method computes for each node the length of the longest link + // from the source, and orders the node in _dp_order according to + // it. It aborts if the graph is not a DAG. int *nb_predecessors = new int[_nb_vertices]; @@ -450,8 +448,8 @@ void MTPGraph::compute_dp_ordering() { for(int k = 0; k < _nb_vertices; k++) { v = &_vertices[k]; for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) { - tv = int(e->terminal_vertex - _vertices); - nb_predecessors[tv]++; + ntv = int(e->terminal_vertex - _vertices); + nb_predecessors[ntv]++; } } @@ -468,10 +466,10 @@ void MTPGraph::compute_dp_ordering() { v = *(already_processed++); v->distance_from_source = rank; for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) { - tv = int(e->terminal_vertex - _vertices); - nb_predecessors[tv]--; - ASSERT(nb_predecessors[tv] >= 0); - if(nb_predecessors[tv] == 0) { + ntv = int(e->terminal_vertex - _vertices); + nb_predecessors[ntv]--; + ASSERT(nb_predecessors[ntv] >= 0); + if(nb_predecessors[ntv] == 0) { *(new_front++) = e->terminal_vertex; } } -- 2.39.5