From 05edb3a8df841ca3b58f7176fb06a2842d19a565 Mon Sep 17 00:00:00 2001 From: Simon Knapp Date: Sun, 29 Oct 2023 11:55:48 +1100 Subject: [PATCH] Fix whitespace errors. --- src/accessibility.cpp | 24 ++++++------ src/accessibility.h | 8 ++-- .../src/BasicDefinitions.h | 2 +- .../src/Contractor/Contractor.h | 2 +- .../src/DataStructures/SimpleCHQuery.h | 26 ++++++------- .../src/DataStructures/StaticGraph.h | 2 +- .../src/Util/HyperThreading.h | 26 ++++++------- src/contraction_hierarchies/src/libch.cpp | 38 +++++++++---------- src/graphalg.cpp | 6 +-- 9 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/accessibility.cpp b/src/accessibility.cpp index 5aa86b5a..f845325c 100644 --- a/src/accessibility.cpp +++ b/src/accessibility.cpp @@ -83,7 +83,7 @@ Accessibility::precomputeRangeQueries(float radius) { vector>> -Accessibility::Range(vector srcnodes, float radius, int graphno, +Accessibility::Range(vector srcnodes, float radius, int graphno, vector ext_ids) { // Set up a mapping between the external node ids and internal ones @@ -91,7 +91,7 @@ Accessibility::Range(vector srcnodes, float radius, int graphno, for (int i = 0; i < ext_ids.size(); i++) { int_ids.insert(pair(ext_ids[i], i)); } - + // use cached results if available vector dists(srcnodes.size()); if (dmsradius > 0 && radius <= dmsradius) { @@ -107,7 +107,7 @@ Accessibility::Range(vector srcnodes, float radius, int graphno, omp_get_thread_num(), dists[i]); } } - + // todo: check that results are returned from cache correctly // todo: check that performing an aggregation creates cache @@ -116,7 +116,7 @@ Accessibility::Range(vector srcnodes, float radius, int graphno, for (int i = 0; i < dists.size(); i++) { output[i].resize(dists[i].size()); for (int j = 0; j < dists[i].size(); j++) { - output[i][j] = std::make_pair(ext_ids[dists[i][j].first], + output[i][j] = std::make_pair(ext_ids[dists[i][j].first], dists[i][j].second); } } @@ -140,7 +140,7 @@ Accessibility::Routes(vector sources, vector targets, int graphno) { #pragma omp parallel #pragma omp for schedule(guided) for (int i = 0 ; i < n ; i++) { - vector ret = this->ga[graphno]->Route(sources[i], targets[i], + vector ret = this->ga[graphno]->Route(sources[i], targets[i], omp_get_thread_num()); routes[i] = vector (ret.begin(), ret.end()); } @@ -155,17 +155,17 @@ Accessibility::Distance(int src, int tgt, int graphno) { vector -Accessibility::Distances(vector sources, vector targets, int graphno) { - +Accessibility::Distances(vector sources, vector targets, int graphno) { + int n = std::min(sources.size(), targets.size()); // in case lists don't match vector distances(n); - + #pragma omp parallel #pragma omp for schedule(guided) for (int i = 0 ; i < n ; i++) { distances[i] = this->ga[graphno]->Distance( - sources[i], - targets[i], + sources[i], + targets[i], omp_get_thread_num()); } return distances; @@ -216,11 +216,11 @@ Accessibility::findNearestPOIs(int srcnode, float maxradius, unsigned number, maxradius, number, omp_get_thread_num()); vector distance_node_pairs; - std::map::iterator cat_for_pois = + std::map::iterator cat_for_pois = accessibilityVarsForPOIs.find(cat); if(cat_for_pois == accessibilityVarsForPOIs.end()) return distance_node_pairs; - + accessibility_vars_t &vars = cat_for_pois->second; /* need to account for the possibility of having diff --git a/src/accessibility.h b/src/accessibility.h index c5e0ad71..ae7997e5 100644 --- a/src/accessibility.h +++ b/src/accessibility.h @@ -46,21 +46,21 @@ class Accessibility { int graphno = 0); // get nodes with a range for a specific list of source nodes - vector>> Range(vector srcnodes, float radius, + vector>> Range(vector srcnodes, float radius, int graphno, vector ext_ids); // shortest path between two points vector Route(int src, int tgt, int graphno = 0); // shortest path between list of origins and destinations - vector> Routes(vector sources, vector targets, + vector> Routes(vector sources, vector targets, int graphno = 0); // shortest path distance between two points double Distance(int src, int tgt, int graphno = 0); - + // shortest path distances between list of origins and destinations - vector Distances(vector sources, vector targets, + vector Distances(vector sources, vector targets, int graphno = 0); // precompute the range queries and reuse them diff --git a/src/contraction_hierarchies/src/BasicDefinitions.h b/src/contraction_hierarchies/src/BasicDefinitions.h index 6e7c5776..62be2ada 100644 --- a/src/contraction_hierarchies/src/BasicDefinitions.h +++ b/src/contraction_hierarchies/src/BasicDefinitions.h @@ -45,4 +45,4 @@ static const int LATLON_MULTIPLIER = 1000000; #define CHASSERT(x,y) do { if( !(x)) {ERR(y)} } while(0); -#endif // BASICDEFINITIONS_H_INCLUDED \ No newline at end of file +#endif // BASICDEFINITIONS_H_INCLUDED diff --git a/src/contraction_hierarchies/src/Contractor/Contractor.h b/src/contraction_hierarchies/src/Contractor/Contractor.h index e2930118..be730c19 100644 --- a/src/contraction_hierarchies/src/Contractor/Contractor.h +++ b/src/contraction_hierarchies/src/Contractor/Contractor.h @@ -111,7 +111,7 @@ class Contractor { _ImportEdge edge; edge.source = i->source(); edge.target = i->target(); - + edge.data.distance = std::max((int)i->weight(), 1 ); assert( edge.data.distance > 0 ); #ifdef DEBUG diff --git a/src/contraction_hierarchies/src/DataStructures/SimpleCHQuery.h b/src/contraction_hierarchies/src/DataStructures/SimpleCHQuery.h index 154c8108..589f574f 100644 --- a/src/contraction_hierarchies/src/DataStructures/SimpleCHQuery.h +++ b/src/contraction_hierarchies/src/DataStructures/SimpleCHQuery.h @@ -1,17 +1,17 @@ /* open source routing machine Copyright (C) Dennis Luxen, others 2010 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -109,19 +109,19 @@ class SimpleCHQuery { void RangeQuery(const NodeID start, const unsigned int maxDistance, std::vector > & resultNodes) { _rangeHeap->Clear(); _rangeHeap->Insert(start, 0, start); - + while(_rangeHeap->Size() > 0) { const NodeID node = _rangeHeap->DeleteMin(); //_forwardHeap->DeleteMin(); const unsigned distance = _rangeHeap->GetKey( node ); //_forwardHeap->GetKey( node ); resultNodes.push_back(std::make_pair(node, distance)); - + for ( typename GraphT::EdgeIterator edge = _range->BeginEdges( node ); edge < _range->EndEdges(node); edge++ ) { const NodeID to = _range->GetTarget(edge); const EdgeWeight edgeWeight = _range->GetEdgeData(edge).distance; - + assert( edgeWeight > 0 ); const unsigned int toDistance = distance + edgeWeight; - + if(toDistance <= maxDistance && _range->GetEdgeData(edge).forward) { //New Node discovered -> Add to Heap + Node Info Storage if ( !_rangeHeap->WasInserted( to ) ) { @@ -137,25 +137,25 @@ class SimpleCHQuery { } } } - + //Don't use in production code. This is for verification purposes only int SimpleDijkstraQuery(const NodeID start, const NodeID target) { HeapT dijkstraHeap( _range->GetNumberOfNodes() ); dijkstraHeap.Insert(start, 0, start); while(dijkstraHeap.Size() > 0) { - const NodeID node = dijkstraHeap.DeleteMin(); + const NodeID node = dijkstraHeap.DeleteMin(); const unsigned distance = dijkstraHeap.GetKey( node ); if(node == target) { return distance; } - + for ( typename GraphT::EdgeIterator edge = _range->BeginEdges( node ); edge < _range->EndEdges(node); edge++ ) { const NodeID to = _range->GetTarget(edge); const EdgeWeight edgeWeight = _range->GetEdgeData(edge).distance; - + assert( edgeWeight > 0 ); const unsigned int toDistance = distance + edgeWeight; - + if(_range->GetEdgeData(edge).forward) { //New Node discovered -> Add to Heap + Node Info Storage if ( !dijkstraHeap.WasInserted( to ) ) { @@ -278,4 +278,4 @@ class SimpleCHQuery { }; -#endif +#endif diff --git a/src/contraction_hierarchies/src/DataStructures/StaticGraph.h b/src/contraction_hierarchies/src/DataStructures/StaticGraph.h index 2d6e3ff6..1f057439 100644 --- a/src/contraction_hierarchies/src/DataStructures/StaticGraph.h +++ b/src/contraction_hierarchies/src/DataStructures/StaticGraph.h @@ -73,7 +73,7 @@ class StaticGraph { _edges[i].target = graph[edge].target; _edges[i].data = graph[edge].data; if(0 >= _edges[i].data.distance) - INFO("i: " << i); + INFO("i: " << i); assert(_edges[i].data.distance > 0); edge++; } diff --git a/src/contraction_hierarchies/src/Util/HyperThreading.h b/src/contraction_hierarchies/src/Util/HyperThreading.h index 4a4ef722..e1e9e10b 100644 --- a/src/contraction_hierarchies/src/Util/HyperThreading.h +++ b/src/contraction_hierarchies/src/Util/HyperThreading.h @@ -1,17 +1,17 @@ /* open source routing machine Copyright (C) Dennis Luxen, others 2010 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -23,7 +23,7 @@ inline void cpuID(unsigned i, unsigned regs[4]) { #ifdef _WIN32 //__cpuid((int *)regs, (int)i); - + #else asm volatile ("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) @@ -34,7 +34,7 @@ inline void cpuID(unsigned i, unsigned regs[4]) { inline int getNumberOfRealCPUs () { unsigned regs[4]; - + // Get vendor char vendor[12]; cpuID(0, regs); @@ -42,12 +42,12 @@ inline int getNumberOfRealCPUs () { ((unsigned *)vendor)[1] = regs[3]; // EDX ((unsigned *)vendor)[2] = regs[2]; // ECX string cpuVendor = string(vendor, 12); - + // Get CPU features cpuID(1, regs); unsigned cpuFeatures = regs[3]; // EDX - - // Detect hyper-threads + + // Detect hyper-threads bool hyperThreads = false; if (cpuVendor == "GenuineIntel" && cpuFeatures & (1 << 28)) { // HTT bit // Logical core count per CPU @@ -55,24 +55,24 @@ inline int getNumberOfRealCPUs () { unsigned logical = (regs[1] >> 16) & 0xff; // EBX[23:16] cout << " logical cpus: " << logical << endl; unsigned cores = logical; - + if (cpuVendor == "GenuineIntel") { // Get DCP cache info cpuID(4, regs); cores = ((regs[0] >> 26) & 0x3f) + 1; // EAX[31:26] + 1 - + } else if (cpuVendor == "AuthenticAMD") { // Get NC: Number of CPU cores - 1 cpuID(0x80000008, regs); cores = ((unsigned)(regs[2] & 0xff)) + 1; // ECX[7:0] + 1 } - + cout << " cpu cores: " << cores << endl; - + if (cores < logical) hyperThreads = true; return cores; } - + cout << "hyper-threads: " << (hyperThreads ? "true" : "false") << endl; return 1; } diff --git a/src/contraction_hierarchies/src/libch.cpp b/src/contraction_hierarchies/src/libch.cpp index d591c055..2f6793ff 100644 --- a/src/contraction_hierarchies/src/libch.cpp +++ b/src/contraction_hierarchies/src/libch.cpp @@ -53,7 +53,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { } poiIndexMap.clear(); queryObjects.clear(); - + //delete all objects, clean up space CHDELETE (contractor ); CHDELETE (staticGraph); @@ -87,7 +87,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { } CHASSERT(ev.size() == this->edgeList.size(), "edge lists sizes differ"); this->contractor = new Contractor( this->nodeVector.size(), this->edgeList ); - this->rangeGraph = BuildRangeGraph(this->nodeVector.size(), this->edgeList); + this->rangeGraph = BuildRangeGraph(this->nodeVector.size(), this->edgeList); } std::string ContractionHierarchies::GetVersionString () { @@ -150,7 +150,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { const NodeID middle = edges[i].data.middleName.nameID; assert(edges[i].data.distance > 0); - + // const short type = 0; //edges[i].data.type; //assert(type >= 0); //remove eigenloops @@ -174,7 +174,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { forwardEdge.data.distance = std::min( edges[i].data.distance, forwardEdge.data.distance ); if ( edges[i].data.backward ) backwardEdge.data.distance = std::min( edges[i].data.distance, backwardEdge.data.distance ); - + assert(edges[i].data.distance > 0); assert(forwardEdge.data.distance > 0); assert(backwardEdge.data.distance > 0); @@ -202,10 +202,10 @@ inline ostream& operator<< (ostream& os, const Edge& e) { } } } - - FILE_LOG(logINFO) << "Range graph removed " << edges.size() - edge + + FILE_LOG(logINFO) << "Range graph removed " << edges.size() - edge << " edges of " << edges.size() << "\n"; - + //INFO("Range graph removed " << edges.size() - edge << " edges of " << edges.size()); assert(edge <= edges.size()); edges.resize( edge ); @@ -242,13 +242,13 @@ inline ostream& operator<< (ostream& os, const Edge& e) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); NodeID start(UINT_MAX); NodeID target(UINT_MAX); - + if(s.id < nodeVector.size()) { start = s.id; } else { return UINT_MAX; } - + if(t.id < nodeVector.size()) { target = t.id; } else { @@ -260,7 +260,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { int ContractionHierarchies::computeShortestPath(const Node &s, const Node& t, vector & ResultingPath){ return computeShortestPath(s, t, ResultingPath, 0); } - + int ContractionHierarchies::computeShortestPath(const Node &s, const Node& t, vector & ResultingPath, unsigned threadID){ CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); CHASSERT(queryObjects.size() > threadID, "Accessing invalid threadID"); @@ -298,7 +298,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { queryObjects[threadID]->RangeQuery(start, maxDistance, ResultingNodes); } - + /** POI queries single threaded */ void ContractionHierarchies::createPOIIndex(const POIKeyType &category, unsigned maxDistanceToConsider, unsigned maxNumberOfPOIsInBucket) @@ -311,7 +311,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { poiIndexMap.insert(CHPOIIndexMap::value_type(category, CHPOIIndex(this->staticGraph, maxDistanceToConsider, maxNumberOfPOIsInBucket, numberOfThreads))); } - + void ContractionHierarchies::addPOIToIndex(const POIKeyType &category, NodeID node) { @@ -320,7 +320,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { if(category_poi != poiIndexMap.end()) category_poi->second.addPOIToIndex(node); } - + void ContractionHierarchies::getNearest(const POIKeyType &category, NodeID node, std::vector& resultingVenues) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); @@ -328,7 +328,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { if(category_poi != poiIndexMap.end()) category_poi->second.getNearestPOIs(node, resultingVenues); } - + void ContractionHierarchies::getNearestWithUpperBoundOnDistance(const POIKeyType &category, NodeID node, EdgeWeight maxDistance, std::vector& resultingVenues) { @@ -346,7 +346,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { if(category_poi != poiIndexMap.end()) category_poi->second.getNearestPOIsWithUpperBoundOnLocations(node, maxLocations, resultingVenues); } - + void ContractionHierarchies::getNearestWithUpperBoundOnDistanceAndLocations(const POIKeyType &category, NodeID node, EdgeWeight maxDistance, unsigned maxLocations, @@ -356,9 +356,9 @@ inline ostream& operator<< (ostream& os, const Edge& e) { if(category_poi != poiIndexMap.end()) category_poi->second.getNearestPOIs(node, resultingVenues, maxDistance, maxLocations); } - - /** POI queries multi-threaded */ + + /** POI queries multi-threaded */ void ContractionHierarchies::getNearest(const POIKeyType &category, NodeID node, std::vector& resultingVenues, unsigned threadID) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); @@ -367,7 +367,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { category_poi->second.getNearestPOIs(node, resultingVenues, threadID); } - + void ContractionHierarchies::getNearestWithUpperBoundOnDistance(const POIKeyType &category, NodeID node, EdgeWeight maxDistance, std::vector& resultingVenues, unsigned threadID) { @@ -376,7 +376,7 @@ inline ostream& operator<< (ostream& os, const Edge& e) { if(category_poi != poiIndexMap.end()) category_poi->second.getNearestPOIsWithUpperBoundOnDistance(node, maxDistance, resultingVenues, threadID); } - + void ContractionHierarchies::getNearestWithUpperBoundOnLocations(const POIKeyType &category, NodeID node, unsigned maxLocations, std::vector& resultingVenues, unsigned threadID) { diff --git a/src/graphalg.cpp b/src/graphalg.cpp index 13ec13f5..4c0be046 100644 --- a/src/graphalg.cpp +++ b/src/graphalg.cpp @@ -9,10 +9,10 @@ Graphalg::Graphalg( this->numnodes = numnodes; int num = omp_get_max_threads(); - + FILE_LOG(logINFO) << "Generating contraction hierarchies with " << num << " threads.\n"; - + ch = CH::ContractionHierarchies(num); vector nv; @@ -39,7 +39,7 @@ Graphalg::Graphalg( FILE_LOG(logINFO) << "Setting CH edge vector of size " << ev.size() << "\n"; - + ch.SetEdgeVector(ev); ch.RunPreprocessing(); }