From: Francois Fleuret Date: Sat, 29 Dec 2012 14:38:21 +0000 (+0100) Subject: OCD cosmetics. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=4370046158668af82bad9e18802b184cb00467b5;p=mtp.git OCD cosmetics. --- diff --git a/mtp_graph.cc b/mtp_graph.cc index e83c848..7cd7e52 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -159,10 +159,10 @@ MTPGraph::MTPGraph(int nb_vertices, int nb_edges, _sink = &_vertices[sink]; for(int e = 0; e < nb_edges; e++) { - _vertices[vertex_from[e]].add_leaving_edge(_edges + e); + _vertices[vertex_from[e]].add_leaving_edge(&_edges[e]); _edges[e].occupied = 0; - _edges[e].origin_vertex = _vertices + vertex_from[e]; - _edges[e].terminal_vertex = _vertices + vertex_to[e]; + _edges[e].origin_vertex = &_vertices[vertex_from[e]]; + _edges[e].terminal_vertex = &_vertices[vertex_to[e]]; } for(int v = 0; v < _nb_vertices; v++) { @@ -214,7 +214,7 @@ void MTPGraph::compute_dp_ranks() { } for(int k = 0; k < _nb_vertices; k++) { - v = _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]++; @@ -232,7 +232,7 @@ void MTPGraph::compute_dp_ranks() { while(nb_without_predecessor > 0) { new_nb_without_predecessor = 0; for(int l = 0; l < nb_without_predecessor; l++) { - v = _vertices + without_predecessor[l]; + v = &_vertices[without_predecessor[l]]; v->distance_from_source = rank; for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) { tv = int(e->terminal_vertex - _vertices); @@ -265,7 +265,7 @@ void MTPGraph::compute_dp_ranks() { void MTPGraph::print(ostream *os) { for(int k = 0; k < _nb_edges; k++) { - Edge *e = _edges + k; + Edge *e = &_edges[k]; (*os) << e->origin_vertex - _vertices << " -> " << e->terminal_vertex - _vertices @@ -283,7 +283,7 @@ void MTPGraph::print_dot(ostream *os) { (*os) << " " << _source - _vertices << " [peripheries=2];" << endl; (*os) << " " << _sink - _vertices << " [peripheries=2];" << endl; for(int k = 0; k < _nb_edges; k++) { - Edge *e = _edges + k; + Edge *e = &_edges[k]; (*os) << " " << e->origin_vertex - _vertices << " -> " @@ -301,7 +301,7 @@ void MTPGraph::print_dot(ostream *os) { void MTPGraph::update_positivized_lengths() { for(int k = 0; k < _nb_edges; k++) { - Edge *e = _edges + k; + Edge *e = &_edges[k]; e->positivized_length += e->origin_vertex->distance_from_source - e->terminal_vertex->distance_from_source; } @@ -313,7 +313,7 @@ void MTPGraph::force_positivized_lengths() { scalar_t max_error = 0.0; #endif for(int k = 0; k < _nb_edges; k++) { - Edge *e = _edges + k; + Edge *e = &_edges[k]; if(e->positivized_length < 0) { #ifdef VERBOSE @@ -456,7 +456,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { // Put back the graph in its original state (i.e. invert edges which // have been inverted in the process) for(int k = 0; k < _nb_edges; k++) { - e = _edges + k; + e = &_edges[k]; if(e->occupied) { e->invert(); } } }