Don't return edge list in contractor but modify graph in-place

This commit is contained in:
Patrick Niklaus
2017-08-19 11:01:32 +00:00
committed by Patrick Niklaus
parent 247f1c120f
commit 421dc5b6ec
4 changed files with 58 additions and 63 deletions
+3 -2
View File
@@ -72,12 +72,13 @@ int Contractor::Run()
util::DeallocatingVector<QueryEdge> contracted_edge_list;
{ // own scope to not keep the contractor around
GraphContractor graph_contractor(toContractorGraph(max_edge_id+1, std::move(edge_based_edge_list)),
auto contractor_graph = toContractorGraph(max_edge_id+1, std::move(edge_based_edge_list));
GraphContractor graph_contractor(contractor_graph,
std::move(node_levels),
std::move(node_weights));
graph_contractor.Run(config.core_factor);
contracted_edge_list = graph_contractor.GetEdges<QueryEdge>();
contracted_edge_list = toEdges<QueryEdge>(std::move(contractor_graph));
is_core_node = graph_contractor.GetCoreMarker();
node_levels = graph_contractor.GetNodeLevels();
}
+5 -4
View File
@@ -5,15 +5,15 @@ namespace osrm
namespace contractor
{
GraphContractor::GraphContractor(ContractorGraph graph_)
: GraphContractor(std::move(graph_), {}, {})
GraphContractor::GraphContractor(ContractorGraph &graph)
: GraphContractor(graph, {}, {})
{
}
GraphContractor::GraphContractor(ContractorGraph graph_,
GraphContractor::GraphContractor(ContractorGraph &graph,
std::vector<float> node_levels_,
std::vector<EdgeWeight> node_weights_)
: graph(std::move(graph_)), orig_node_id_from_new_node_id_map(graph.GetNumberOfNodes()),
: graph(graph), orig_node_id_from_new_node_id_map(graph.GetNumberOfNodes()),
node_levels(std::move(node_levels_)), node_weights(std::move(node_weights_))
{
// Fill the map with an identiy mapping
@@ -307,6 +307,7 @@ void GraphContractor::Run(double core_factor)
util::inplacePermutation(node_levels.begin(), node_levels.end(), orig_node_id_from_new_node_id_map);
util::inplacePermutation(is_core_node.begin(), is_core_node.end(), orig_node_id_from_new_node_id_map);
graph.Renumber(orig_node_id_from_new_node_id_map);
thread_data_list.data.clear();
}