X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mtp_graph.cc;h=c213a07ed51bab57f183432f24797921f4f9998f;hb=fda29b3422f4850d77e4b8f4916251509789d3ac;hp=32bdfdfe69dfe292db6d63749947e0eed09488c1;hpb=897732507b36b4fc2099f7c54536d278a93d4531;p=mtp.git diff --git a/mtp_graph.cc b/mtp_graph.cc index 32bdfdf..c213a07 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -135,35 +135,35 @@ MTPGraph::~MTPGraph() { ////////////////////////////////////////////////////////////////////// -void MTPGraph::print() { +void MTPGraph::print(ostream *os) { for(int k = 0; k < _nb_edges; k++) { Edge *e = _edges + k; - cout << e->origin_vertex->id + (*os) << e->origin_vertex->id << " -> " << e->terminal_vertex->id << " " << e->length; if(e->occupied) { - cout << " *"; + (*os) << " *"; } - cout << endl; + (*os) << endl; } } -void MTPGraph::print_dot() { - cout << "digraph {" << endl; - cout << " node[shape=circle];" << endl; +void MTPGraph::print_dot(ostream *os) { + (*os) << "digraph {" << endl; + (*os) << " node[shape=circle];" << endl; for(int k = 0; k < _nb_edges; k++) { Edge *e = _edges + k; if(e->occupied) { - cout << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id - << " [style=bold,color=black,label=\"" << -e->length << "\"];" << endl; + (*os) << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id + << " [style=bold,color=black,label=\"" << e->length << "\"];" << endl; } else { - cout << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id + (*os) << " " << e->origin_vertex->id << " -> " << e->terminal_vertex->id << " [color=gray,label=\"" << e->length << "\"];" << endl; } } - cout << "}" << endl; + (*os) << "}" << endl; } ////////////////////////////////////////////////////////////////////// @@ -265,6 +265,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { for(int e = 0; e < _nb_edges; e++) { _edges[e].length = lengths[e]; + _edges[e].occupied = 0; _edges[e].positivized_length = _edges[e].length; } @@ -294,7 +295,7 @@ void MTPGraph::find_best_paths(scalar_t *lengths) { // If that length is negative if(total_length < 0.0) { #ifdef VERBOSE - cout << "Found a path of length " << total_length << endl; + cerr << "Found a path of length " << total_length << endl; #endif // Invert all the edges along the best path v = _sink;