X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mtp_graph.cc;h=6537a7fe062318d05ad9c6577191e9654e88888d;hb=09c2607f1569a54f9f77ee5006148937044ee79d;hp=c456601d2c76bb9cc5ef939d561cda3bfaad44dc;hpb=7cbab96fbb1061a665956c8b65f4876d5f02c094;p=mtp.git diff --git a/mtp_graph.cc b/mtp_graph.cc index c456601..6537a7f 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -24,7 +24,6 @@ #include "mtp_graph.h" -// #include #include using namespace std; @@ -161,9 +160,6 @@ void MTPGraph::print_dot(ostream *os) { (*os) << " " << _sink->id << " [peripheries=2];" << endl; for(int k = 0; k < _nb_edges; k++) { Edge *e = _edges + k; - // (*os) << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id - // << ";" - // << endl; (*os) << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id << " ["; if(e->occupied) { @@ -377,7 +373,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { int MTPGraph::retrieve_one_path(Edge *e, Path *path) { Edge *f, *next = 0; - int l = 0; + int l = 0, nb_occupied_next; if(path) { path->nodes[l++] = e->origin_vertex->id; @@ -389,17 +385,19 @@ int MTPGraph::retrieve_one_path(Edge *e, Path *path) { path->nodes[l++] = e->terminal_vertex->id; path->length += e->length; } else l++; - int nb_choices = 0; + + nb_occupied_next = 0; for(f = e->terminal_vertex->leaving_edges; f; f = f->next_leaving_edge) { - if(f->occupied) { nb_choices++; next = f; } + if(f->occupied) { nb_occupied_next++; next = f; } } #ifdef DEBUG - if(nb_choices == 0) { + if(nb_occupied_next == 0) { cerr << "retrieve_one_path: Non-sink end point." << endl; abort(); } - if(nb_choices > 1) { + + else if(nb_occupied_next > 1) { cerr << "retrieve_one_path: Non node-disjoint paths." << endl; abort(); } @@ -418,6 +416,7 @@ int MTPGraph::retrieve_one_path(Edge *e, Path *path) { void MTPGraph::retrieve_disjoint_paths() { Edge *e; + int p, l; for(int p = 0; p < nb_paths; p++) delete paths[p]; delete[] paths; @@ -429,10 +428,10 @@ void MTPGraph::retrieve_disjoint_paths() { paths = new Path *[nb_paths]; - int p = 0; + p = 0; for(e = _source->leaving_edges; e; e = e->next_leaving_edge) { if(e->occupied) { - int l = retrieve_one_path(e, 0); + l = retrieve_one_path(e, 0); paths[p] = new Path(l); retrieve_one_path(e, paths[p]); p++;