X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mtp.git;a=blobdiff_plain;f=mtp_graph.cc;h=473d13ecb5a99bf6ec713fc9aca3500591ed3bbd;hp=9a811bba9ae5095b625cd7589c0bfdd024d2c298;hb=2c79f2f3d73d7dc7a8c799ad9386484a5a684ca4;hpb=34022d5e987cf13ff6db31a6d7263e9266a8b1c0 diff --git a/mtp_graph.cc b/mtp_graph.cc index 9a811bb..473d13e 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -232,7 +232,7 @@ int MTPGraph::is_dag() { } new_front_size = 0; - // We remove all vertex without incoming edge + // We remove all the vertices without incoming edge for(int f = 0; f < front_size; f++) { v = _front[f]; if(v->iteration == iteration) { @@ -247,8 +247,10 @@ int MTPGraph::is_dag() { return front_size == 0; } -// 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. + void MTPGraph::find_shortest_path() { Vertex **tmp_front; int tmp_front_size; @@ -312,8 +314,9 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { // 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 use call find_shortest_path here to set properly the distance, + // so that we can make all the edge lengths positive at the first + // iteration. find_shortest_path(); do { @@ -323,7 +326,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { total_length = 0.0; - // Do we reach the _sink? + // Do we reach the sink? if(_sink->pred_edge_toward_source) { // If yes, compute the length of the best path v = _sink;