diff --git a/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.cpp b/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.cpp index b6781c18..12d90774 100644 --- a/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.cpp +++ b/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.cpp @@ -201,21 +201,23 @@ HGEdge::~HGEdge() } // compute an edge label, optionally resticted by systems -std::string HGEdge::label(std::list *systems) -{ std::string the_label; +void HGEdge::write_label(std::ofstream& file, std::list *systems) +{ bool write_comma = 0; for (std::pair &ns : route_names_and_systems) { // test whether system in systems if (!systems || contains(*systems, ns.second)) - if (the_label.empty()) - the_label = ns.first; - else the_label += "," + ns.first; + if (!write_comma) + { file << ns.first; + write_comma = 1; + } + else file << "," << ns.first; } - return the_label; } // write line to tmg collapsed edge file void HGEdge::collapsed_tmg_line(std::ofstream& file, char* fstr, unsigned int threadnum, std::list *systems) -{ file << vertex1->c_vertex_num[threadnum] << ' ' << vertex2->c_vertex_num[threadnum] << ' ' << label(systems); +{ file << vertex1->c_vertex_num[threadnum] << ' ' << vertex2->c_vertex_num[threadnum] << ' '; + write_label(file, systems); for (HGVertex *intermediate : intermediate_points) { sprintf(fstr, " %.15g %.15g", intermediate->lat, intermediate->lng); file << fstr; @@ -225,7 +227,8 @@ void HGEdge::collapsed_tmg_line(std::ofstream& file, char* fstr, unsigned int th // write line to tmg traveled edge file void HGEdge::traveled_tmg_line(std::ofstream& file, char* fstr, unsigned int threadnum, std::list *systems, std::list *traveler_lists) -{ file << vertex1->t_vertex_num[threadnum] << ' ' << vertex2->t_vertex_num[threadnum] << ' ' << label(systems); +{ file << vertex1->t_vertex_num[threadnum] << ' ' << vertex2->t_vertex_num[threadnum] << ' '; + write_label(file, systems); file << ' ' << segment->clinchedby_code(traveler_lists, threadnum); for (HGVertex *intermediate : intermediate_points) { sprintf(fstr, " %.15g %.15g", intermediate->lat, intermediate->lng); @@ -234,7 +237,7 @@ void HGEdge::traveled_tmg_line(std::ofstream& file, char* fstr, unsigned int thr file << '\n'; } -// line appropriate for a tmg collapsed edge file, with debug info +/* line appropriate for a tmg collapsed edge file, with debug info std::string HGEdge::debug_tmg_line(std::list *systems, unsigned int threadnum) { std::string line = std::to_string(vertex1->c_vertex_num[threadnum]) + " [" + *vertex1->unique_name + "] " \ + std::to_string(vertex2->c_vertex_num[threadnum]) + " [" + *vertex2->unique_name + "] " + label(systems); @@ -244,7 +247,7 @@ std::string HGEdge::debug_tmg_line(std::list *systems, unsigned line += " [" + *intermediate->unique_name + fstr; } return line; -} +}*/ // printable string for this edge std::string HGEdge::str() diff --git a/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.h b/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.h index 7c40cba8..b3bb4e7e 100644 --- a/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.h +++ b/siteupdate/cplusplus/classes/GraphGeneration/HGEdge.h @@ -29,7 +29,7 @@ class HGEdge ~HGEdge(); void detach(unsigned char); - std::string label(std::list *); + void write_label(std::ofstream&, std::list *); void collapsed_tmg_line(std::ofstream&, char*, unsigned int, std::list*); void traveled_tmg_line (std::ofstream&, char*, unsigned int, std::list*, std::list*); std::string debug_tmg_line(std::list *, unsigned int); diff --git a/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp b/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp index 2fdd3e05..5298ea43 100644 --- a/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp +++ b/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp @@ -309,7 +309,9 @@ void HighwayGraph::write_master_graphs_tmg(std::vector &graph_ve { for (HGEdge *e : wv.second->incident_s_edges) if (!e->s_written) { e->s_written = 1; - simplefile << e->vertex1->s_vertex_num[0] << ' ' << e->vertex2->s_vertex_num[0] << ' ' << e->label(0) << '\n'; + simplefile << e->vertex1->s_vertex_num[0] << ' ' << e->vertex2->s_vertex_num[0] << ' '; + e->write_label(simplefile, 0); + simplefile << '\n'; } // write edges if vertex is visible... if (wv.second->visibility >= 1) @@ -408,9 +410,11 @@ void HighwayGraph::write_subgraphs_tmg } // write edges for (HGEdge *e : mse) - simplefile << e->vertex1->s_vertex_num[threadnum] << ' ' - << e->vertex2->s_vertex_num[threadnum] << ' ' - << e->label(graph_vector[graphnum].systems) << '\n'; + { simplefile << e->vertex1->s_vertex_num[threadnum] << ' ' + << e->vertex2->s_vertex_num[threadnum] << ' '; + e->write_label(simplefile, graph_vector[graphnum].systems); + simplefile << '\n'; + } char fstr[57]; for (HGEdge *e : mce) e->collapsed_tmg_line(collapfile, fstr, threadnum, graph_vector[graphnum].systems);