- for(int n = 0; n < _nb_vertices; n++) {
- for(Edge *e = vertices[n].root_edge; e; e = e->next) {
- e->work_length = e->length - length_min;
+
+ scalar_t rank = 1;
+ 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_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_unreached = nb_unreached;
+ nb_unreached = 0;
+
+ // We keep all the vertices with incoming nodes
+ for(int f = 0; f < pred_nb_unreached; f++) {
+ v = unreached[f];
+ if(v->distance_from_source == rank) {
+ unreached[nb_unreached++] = v;
+ }
+ }
+
+ rank++;
+ } while(nb_unreached < pred_nb_unreached);
+
+ delete[] unreached;
+
+ return nb_unreached == 0;
+}
+
+//////////////////////////////////////////////////////////////////////
+
+void MTPGraph::print(ostream *os) {
+ for(int k = 0; k < _nb_edges; k++) {
+ Edge *e = _edges + k;
+ (*os) << e->origin_vertex - _vertices
+ << " -> "
+ << e->terminal_vertex - _vertices
+ << " "
+ << e->length;
+ if(e->occupied) {
+ (*os) << " *";