origin_vertex->del_leaving_edge(this);
terminal_vertex->add_leaving_edge(this);
Vertex *t = terminal_vertex;
origin_vertex->del_leaving_edge(this);
terminal_vertex->add_leaving_edge(this);
Vertex *t = terminal_vertex;
(*os) << " node [shape=circle,width=0.75,fixedsize=true];" << endl;
(*os) << " edge [color=gray,arrowhead=open]" << endl;
(*os) << " " << _source->id << " [peripheries=2];" << endl;
(*os) << " node [shape=circle,width=0.75,fixedsize=true];" << endl;
(*os) << " edge [color=gray,arrowhead=open]" << endl;
(*os) << " " << _source->id << " [peripheries=2];" << endl;
// We set the iteration field of all vertex with incoming edges to
// the current iteration value
for(int f = 0; f < front_size; f++) {
v = _front[f];
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
// We set the iteration field of all vertex with incoming edges to
// the current iteration value
for(int f = 0; f < front_size; f++) {
v = _front[f];
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
- new_front_size = 0;
- // We remove all vertex without incoming edge
- for(int f = 0; f < front_size; f++) {
+ pred_front_size = front_size;
+ front_size = 0;
+
+ // We remove all the vertices without incoming edge
+ for(int f = 0; f < pred_front_size; f++) {
-// This method does not change the edge occupation. It update
-// distance_from_source and pred_edge_toward_source.
+// This method does not change the edge occupation. It only set
+// properly for every vertex the fields distance_from_source and
+// pred_edge_toward_source.
+
+#ifdef DEBUG
+ if(is_dag()) {
+ cout << "find_shortest_path: DAG -> ok" << endl;
+ } else {
+ for(int e = 0; e < _nb_edges; e++) {
+ if(_edges[e].positivized_length < 0) abort();
+ }
+ cout << "find_shortest_path: All positivized_length are positive -> ok" << endl;
+ }
+#endif
+
for(int k = 0; k < _nb_vertices; k++) {
_vertices[k].distance_from_source = FLT_MAX;
_vertices[k].pred_edge_toward_source = 0;
for(int k = 0; k < _nb_vertices; k++) {
_vertices[k].distance_from_source = FLT_MAX;
_vertices[k].pred_edge_toward_source = 0;
if(d < tv->distance_from_source) {
tv->distance_from_source = d;
tv->pred_edge_toward_source = e;
if(d < tv->distance_from_source) {
tv->distance_from_source = d;
tv->pred_edge_toward_source = e;
- // Let's be a bit paranoid
- ASSERT(is_dag());
-
- // We use one iteration of find_shortest_path simply to propagate
- // the distance to make all the edge lengths positive.
+ // We call find_shortest_path here to set properly the distances to
+ // the source, so that we can make all the edge lengths positive at
+ // the first iteration.