Initial version of core ch

This improves preprocessing times in favour of worse query performance.
Core size can be set over the --core parameater, default is the old
behaviour to fully contract the graph.
This commit is contained in:
MoKob
2015-07-13 21:09:19 +02:00
committed by Patrick Niklaus
parent 94f44e1d5d
commit b526cadebd
10 changed files with 211 additions and 12 deletions
+6 -4
View File
@@ -284,7 +284,7 @@ class Contractor
~Contractor() {}
void Run()
void Run( double core_factor = 1.0 )
{
// for the preperation we can use a big grain size, which is much faster (probably cache)
constexpr size_t InitGrainSize = 100000;
@@ -333,9 +333,9 @@ class Contractor
<< std::flush;
bool flushed_contractor = false;
while (number_of_nodes > 2 && number_of_contracted_nodes < number_of_nodes)
while (number_of_nodes > 2 && number_of_contracted_nodes < static_cast<NodeID>(number_of_nodes * core_factor) )
{
if (!flushed_contractor && (number_of_contracted_nodes > (number_of_nodes * 0.65)))
if (!flushed_contractor && (number_of_contracted_nodes > static_cast<NodeID>(number_of_nodes * 0.65 * core_factor)))
{
DeallocatingVector<ContractorEdge> new_edge_set; // this one is not explicitely
// cleared since it goes out of
@@ -524,7 +524,7 @@ class Contractor
// unsigned quaddegree = 0;
//
// for(unsigned i = 0; i < remaining_nodes.size(); ++i) {
// unsigned degree = contractor_graph->EndEdges(remaining_nodes[i].first)
// unsigned degree = contractor_graph->EndEdges(remaining_nodes[i].id)
// -
// contractor_graph->BeginEdges(remaining_nodes[i].first);
// if(degree > maxdegree)
@@ -546,6 +546,8 @@ class Contractor
p.printStatus(number_of_contracted_nodes);
}
SimpleLogger().Write() << "[core] " << remaining_nodes.size() << " nodes " << contractor_graph->GetNumberOfEdges() << " edges." << std::endl;
thread_data_list.data.clear();
}
+5 -1
View File
@@ -56,7 +56,11 @@ ContractorOptions::ParseArguments(int argc, char *argv[], ContractorConfig &cont
"Path to LUA routing profile")(
"threads,t", boost::program_options::value<unsigned int>(&contractor_config.requested_num_threads)
->default_value(tbb::task_scheduler_init::default_num_threads()),
"Number of threads to use");
"Number of threads to use")(
"core,k", boost::program_options::value<double>(&contractor_config.core_factor)
->default_value(1.0),"Percentage of the graph (in vertices) to contract [0.1]");
// hidden options, will be allowed both on command line and in config file, but will not be
// shown to the user
+6
View File
@@ -56,6 +56,12 @@ struct ContractorConfig
std::string rtree_leafs_output_path;
unsigned requested_num_threads;
//A percentage of vertices that will be contracted for the hierarchy.
//Offers a trade-off between preprocessing and query time.
//The remaining vertices form the core of the hierarchy
//(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
double core_factor;
};
struct ContractorOptions
+1 -1
View File
@@ -414,7 +414,7 @@ void Prepare::ContractGraph(const unsigned max_edge_id,
DeallocatingVector<QueryEdge>& contracted_edge_list)
{
Contractor contractor(max_edge_id + 1, edge_based_edge_list);
contractor.Run();
contractor.Run(config.core_factor);
contractor.GetEdges(contracted_edge_list);
}