remove core factor opt from exclude graph

This commit is contained in:
karenzshea 2017-10-12 19:12:54 +02:00 committed by Patrick Niklaus
parent df79b5b4cc
commit 4f3414c4cc
3 changed files with 12 additions and 24 deletions

View File

@ -13,12 +13,11 @@ namespace contractor
{ {
using GraphFilterAndCore = using GraphFilterAndCore =
std::tuple<QueryGraph, std::vector<std::vector<bool>>, std::vector<std::vector<bool>>>; std::tuple<QueryGraph, std::vector<std::vector<bool>>>;
inline auto contractExcludableGraph(ContractorGraph contractor_graph_, inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
std::vector<EdgeWeight> node_weights, std::vector<EdgeWeight> node_weights,
const std::vector<std::vector<bool>> &filters, const std::vector<std::vector<bool>> &filters)
const float core_factor = 1.0)
{ {
auto num_nodes = contractor_graph_.GetNumberOfNodes(); auto num_nodes = contractor_graph_.GetNumberOfNodes();
ContractedEdgeContainer edge_container; ContractedEdgeContainer edge_container;
@ -42,7 +41,7 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
is_shared_core = contractGraph(contractor_graph, is_shared_core = contractGraph(contractor_graph,
std::move(always_allowed), std::move(always_allowed),
node_weights, node_weights,
std::min<float>(BASE_CORE, core_factor)); BASE_CORE);
// Add all non-core edges to container // Add all non-core edges to container
{ {
@ -60,26 +59,16 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
[&is_shared_core](const NodeID node) { return is_shared_core[node]; }); [&is_shared_core](const NodeID node) { return is_shared_core[node]; });
} }
std::vector<std::vector<bool>> cores;
for (const auto &filter : filters) for (const auto &filter : filters)
{ {
auto filtered_core_graph = auto filtered_core_graph =
shared_core_graph.Filter([&filter](const NodeID node) { return filter[node]; }); shared_core_graph.Filter([&filter](const NodeID node) { return filter[node]; });
auto core = contractGraph(
filtered_core_graph, is_shared_core, is_shared_core, node_weights, core_factor);
if (core_factor == 1.0)
{
core.clear();
}
cores.push_back(std::move(core));
edge_container.Merge(toEdges<QueryEdge>(std::move(filtered_core_graph))); edge_container.Merge(toEdges<QueryEdge>(std::move(filtered_core_graph)));
} }
return GraphFilterAndCore{QueryGraph{num_nodes, std::move(edge_container.edges)}, return GraphFilterAndCore{QueryGraph{num_nodes, std::move(edge_container.edges)},
edge_container.MakeEdgeFilters(), edge_container.MakeEdgeFilters()};
std::move(cores)};
} }
} }
} }

View File

@ -95,11 +95,10 @@ int Contractor::Run()
QueryGraph query_graph; QueryGraph query_graph;
std::vector<std::vector<bool>> edge_filters; std::vector<std::vector<bool>> edge_filters;
std::vector<std::vector<bool>> cores; std::vector<std::vector<bool>> cores;
std::tie(query_graph, edge_filters, cores) = contractExcludableGraph( std::tie(query_graph, edge_filters) = contractExcludableGraph(
toContractorGraph(number_of_edge_based_nodes, std::move(edge_based_edge_list)), toContractorGraph(number_of_edge_based_nodes, std::move(edge_based_edge_list)),
std::move(node_weights), std::move(node_weights),
std::move(node_filters), std::move(node_filters));
config.core_factor);
TIMER_STOP(contraction); TIMER_STOP(contraction);
util::Log() << "Contracted graph has " << query_graph.GetNumberOfEdges() << " edges."; util::Log() << "Contracted graph has " << query_graph.GetNumberOfEdges() << " edges.";
util::Log() << "Contraction took " << TIMER_SEC(contraction) << " sec"; util::Log() << "Contraction took " << TIMER_SEC(contraction) << " sec";

View File

@ -49,12 +49,12 @@ return_code parseArguments(int argc,
"Number of threads to use")( "Number of threads to use")(
"core,k", "core,k",
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0), boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
"DEPRECATED: Will always be 1.0. Percentage of the graph (in vertices) to contract [0..1].")( "DEPRECATED: Will always be 1.0. Percentage of the graph (in vertices) to contract "
"segment-speed-file", "[0..1].")("segment-speed-file",
boost::program_options::value<std::vector<std::string>>( boost::program_options::value<std::vector<std::string>>(
&contractor_config.updater_config.segment_speed_lookup_paths) &contractor_config.updater_config.segment_speed_lookup_paths)
->composing(), ->composing(),
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")( "Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
"turn-penalty-file", "turn-penalty-file",
boost::program_options::value<std::vector<std::string>>( boost::program_options::value<std::vector<std::string>>(
&contractor_config.updater_config.turn_penalty_lookup_paths) &contractor_config.updater_config.turn_penalty_lookup_paths)