+ // 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++) {
+ Edge *e = _edges + k;
+ if(e->occupied) { e->invert(); }
+ }
+}
+
+int MTPGraph::retrieve_one_path(Edge *e, Path *path) {
+ Edge *f, *next = 0;
+ int l = 0;
+
+ if(path) {
+ path->nodes[l++] = e->origin_vertex->id;
+ path->length = e->length;
+ } else l++;
+
+ while(e->terminal_vertex != _sink) {
+ if(path) {
+ path->nodes[l++] = e->terminal_vertex->id;
+ path->length += e->length;
+ } else l++;
+ int nb_choices = 0;
+ for(f = e->terminal_vertex->leaving_edges; f; f = f->next_leaving_edge) {
+ if(f->occupied) { nb_choices++; next = f; }
+ if(nb_choices == 0) {
+ cerr << "retrieve_one_path: Non-sink end point." << endl;
+ abort();
+ }
+ if(nb_choices > 1) {
+ cerr << "retrieve_one_path: Non node-disjoint paths." << endl;
+ abort();
+ }
+ }
+ e = next;
+ }
+
+ if(path) {
+ path->nodes[l++] = e->terminal_vertex->id;
+ path->length += e->length;
+ } else l++;