X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mtp.git;a=blobdiff_plain;f=mtp_graph.cc;h=95ef485d5166579153e68209dd90a97ab5b1b76c;hp=9a811bba9ae5095b625cd7589c0bfdd024d2c298;hb=342c65f1c9deda8de361227afe26c7cd8b46d7c2;hpb=34022d5e987cf13ff6db31a6d7263e9266a8b1c0 diff --git a/mtp_graph.cc b/mtp_graph.cc index 9a811bb..95ef485 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -153,6 +153,7 @@ void MTPGraph::print(ostream *os) { void MTPGraph::print_dot(ostream *os) { (*os) << "digraph {" << endl; + (*os) << " rankdir=\"LR\";" << endl; (*os) << " node [shape=circle,width=0.75,fixedsize=true];" << endl; (*os) << " edge [color=gray,arrowhead=open]" << endl; (*os) << " " << _source->id << " [peripheries=2];" << endl; @@ -232,7 +233,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 +248,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 +315,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 +327,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;