Skip to content

Commit fcb7dd2

Browse files
committed
format code
1 parent aa06029 commit fcb7dd2

File tree

7 files changed

+111
-99
lines changed

7 files changed

+111
-99
lines changed

include/engine/routing_algorithms/routing_base_ch.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ch
2424
// Stalling
2525
template <bool DIRECTION, typename HeapT>
2626
bool stallAtNode(const DataFacade<Algorithm> &facade,
27-
const typename HeapT::HeapNode& heapNode,
27+
const typename HeapT::HeapNode &heapNode,
2828
const HeapT &query_heap)
2929
{
3030
for (auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
@@ -35,7 +35,7 @@ bool stallAtNode(const DataFacade<Algorithm> &facade,
3535
const NodeID to = facade.GetTarget(edge);
3636
const EdgeWeight edge_weight = data.weight;
3737
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
38-
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
38+
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
3939
if (toHeapNode)
4040
{
4141
if (toHeapNode->weight + edge_weight < heapNode.weight)
@@ -50,7 +50,7 @@ bool stallAtNode(const DataFacade<Algorithm> &facade,
5050

5151
template <bool DIRECTION>
5252
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
53-
const SearchEngineData<Algorithm>::QueryHeap::HeapNode& heapNode,
53+
const SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
5454
SearchEngineData<Algorithm>::QueryHeap &heap)
5555
{
5656
for (const auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
@@ -75,7 +75,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
7575
{
7676
// new parent
7777
toHeapNode->data.parent = heapNode.node;
78-
toHeapNode->weight=to_weight;
78+
toHeapNode->weight = to_weight;
7979
heap.DecreaseKey(*toHeapNode);
8080
}
8181
}

include/engine/routing_algorithms/routing_base_mld.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
9797
const std::vector<std::size_t> &phantom_indices)
9898
{
9999
auto min_level = [&partition, node](const PhantomNode &phantom_node) {
100-
101100
const auto &forward_segment = phantom_node.forward_segment_id;
102101
const auto forward_level =
103102
forward_segment.enabled ? partition.GetHighestDifferentLevel(node, forward_segment.id)
@@ -120,7 +119,7 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
120119
}
121120
return result;
122121
}
123-
}
122+
} // namespace
124123

125124
// Heaps only record for each node its predecessor ("parent") on the shortest path.
126125
// For re-constructing the actual path we need to trace back all parent "pointers".
@@ -229,7 +228,7 @@ retrievePackedPathFromHeap(const SearchEngineData<Algorithm>::QueryHeap &forward
229228
template <bool DIRECTION, typename Algorithm, typename... Args>
230229
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
231230
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
232-
const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode& heapNode,
231+
const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
233232
Args... args)
234233
{
235234
const auto &partition = facade.GetMultiLevelPartition();
@@ -243,7 +242,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
243242
if (DIRECTION == FORWARD_DIRECTION)
244243
{
245244
// Shortcuts in forward direction
246-
const auto &cell = cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
245+
const auto &cell =
246+
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
247247
auto destination = cell.GetDestinationNodes().begin();
248248
for (auto shortcut_weight : cell.GetOutWeight(heapNode.node))
249249
{
@@ -262,7 +262,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
262262
else if (to_weight < toHeapNode->weight)
263263
{
264264
toHeapNode->data = {heapNode.node, true};
265-
toHeapNode->weight=to_weight;
265+
toHeapNode->weight = to_weight;
266266
forward_heap.DecreaseKey(*toHeapNode);
267267
}
268268
}
@@ -272,7 +272,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
272272
else
273273
{
274274
// Shortcuts in backward direction
275-
const auto &cell = cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
275+
const auto &cell =
276+
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
276277
auto source = cell.GetSourceNodes().begin();
277278
for (auto shortcut_weight : cell.GetInWeight(heapNode.node))
278279
{
@@ -291,7 +292,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
291292
else if (to_weight < toHeapNode->weight)
292293
{
293294
toHeapNode->data = {heapNode.node, true};
294-
toHeapNode->weight=to_weight;
295+
toHeapNode->weight = to_weight;
295296
forward_heap.DecreaseKey(*toHeapNode);
296297
}
297298
}
@@ -328,8 +329,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
328329
}
329330
else if (to_weight < toHeapNode->weight)
330331
{
331-
toHeapNode->data = {heapNode.node, false};
332-
toHeapNode->weight=to_weight;
332+
toHeapNode->data = {heapNode.node, false};
333+
toHeapNode->weight = to_weight;
333334
forward_heap.DecreaseKey(*toHeapNode);
334335
}
335336
}

include/util/query_heap.hpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define OSRM_UTIL_QUERY_HEAP_HPP
33

44
#include <boost/assert.hpp>
5-
#include <boost/optional.hpp>
65
#include <boost/heap/d_ary_heap.hpp>
6+
#include <boost/optional.hpp>
77

88
#include <algorithm>
99
#include <limits>
@@ -196,12 +196,11 @@ template <typename NodeID,
196196
class QueryHeap
197197
{
198198
private:
199-
200199
using HeapData = std::pair<Weight, Key>;
201200
using HeapContainer = boost::heap::d_ary_heap<HeapData,
202-
boost::heap::arity<4>,
203-
boost::heap::mutable_<true>,
204-
boost::heap::compare<std::greater<HeapData>>>;
201+
boost::heap::arity<4>,
202+
boost::heap::mutable_<true>,
203+
boost::heap::compare<std::greater<HeapData>>>;
205204
using HeapHandle = typename HeapContainer::handle_type;
206205

207206
public:
@@ -248,7 +247,7 @@ class QueryHeap
248247
return inserted_nodes[index].data;
249248
}
250249

251-
HeapNode& getHeapNode(NodeID node)
250+
HeapNode &getHeapNode(NodeID node)
252251
{
253252
const auto index = node_index.peek_index(node);
254253
BOOST_ASSERT((int)index >= 0 && (int)index < (int)inserted_nodes.size());
@@ -294,28 +293,28 @@ class QueryHeap
294293
return inserted_nodes[index].node == node;
295294
}
296295

297-
boost::optional<HeapNode&> GetHeapNodeIfWasInserted(const NodeID node)
296+
boost::optional<HeapNode &> GetHeapNodeIfWasInserted(const NodeID node)
298297
{
299298
const auto index = node_index.peek_index(node);
300-
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) || inserted_nodes[index].node!=node)
299+
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) ||
300+
inserted_nodes[index].node != node)
301301
{
302302
return {};
303303
}
304304
return inserted_nodes[index];
305305
}
306306

307-
boost::optional<const HeapNode&> GetHeapNodeIfWasInserted(const NodeID node) const
307+
boost::optional<const HeapNode &> GetHeapNodeIfWasInserted(const NodeID node) const
308308
{
309309
const auto index = node_index.peek_index(node);
310-
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) || inserted_nodes[index].node!=node)
310+
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) ||
311+
inserted_nodes[index].node != node)
311312
{
312313
return {};
313314
}
314315
return inserted_nodes[index];
315316
}
316317

317-
318-
319318
NodeID Min() const
320319
{
321320
BOOST_ASSERT(!heap.empty());
@@ -337,7 +336,7 @@ class QueryHeap
337336
return inserted_nodes[removedIndex].node;
338337
}
339338

340-
HeapNode& DeleteMinGetHeapNode()
339+
HeapNode &DeleteMinGetHeapNode()
341340
{
342341
BOOST_ASSERT(!heap.empty());
343342
const Key removedIndex = heap.top().second;
@@ -364,7 +363,7 @@ class QueryHeap
364363
heap.increase(reference.handle, std::make_pair(weight, index));
365364
}
366365

367-
void DecreaseKey(const HeapNode& heapNode)
366+
void DecreaseKey(const HeapNode &heapNode)
368367
{
369368
BOOST_ASSERT(!WasRemoved(heapNode.node));
370369
heap.increase(heapNode.handle, std::make_pair(heapNode.weight, (*heapNode.handle).second));
@@ -375,7 +374,7 @@ class QueryHeap
375374
HeapContainer heap;
376375
IndexStorage node_index;
377376
};
378-
}
379-
}
377+
} // namespace util
378+
} // namespace osrm
380379

381380
#endif // OSRM_UTIL_QUERY_HEAP_HPP

src/contractor/contractor_search.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void relaxNode(ContractorHeap &heap,
3232
}
3333
const EdgeWeight to_weight = node_weight + data.weight;
3434

35-
const auto toHeapNode= heap.GetHeapNodeIfWasInserted(to);
35+
const auto toHeapNode = heap.GetHeapNodeIfWasInserted(to);
3636
// New Node discovered -> Add to Heap + Node Info Storage
3737
if (!toHeapNode)
3838
{
@@ -41,13 +41,13 @@ void relaxNode(ContractorHeap &heap,
4141
// Found a shorter Path -> Update weight
4242
else if (to_weight < toHeapNode->weight)
4343
{
44-
toHeapNode->weight=to_weight;
44+
toHeapNode->weight = to_weight;
4545
heap.DecreaseKey(*toHeapNode);
4646
toHeapNode->data.hop = current_hop;
4747
}
4848
}
4949
}
50-
}
50+
} // namespace
5151

5252
void search(ContractorHeap &heap,
5353
const ContractorGraph &graph,
@@ -85,5 +85,5 @@ void search(ContractorHeap &heap,
8585
relaxNode(heap, graph, node, node_weight, forbidden_node);
8686
}
8787
}
88-
}
89-
}
88+
} // namespace contractor
89+
} // namespace osrm

src/engine/routing_algorithms/alternative_path_ch.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
6262
QueryHeap &forward_heap = DIRECTION == FORWARD_DIRECTION ? heap1 : heap2;
6363
QueryHeap &reverse_heap = DIRECTION == FORWARD_DIRECTION ? heap2 : heap1;
6464

65-
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if toHeapNode is the same
66-
const auto heapNode=forward_heap.DeleteMinGetHeapNode();
65+
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if
66+
// toHeapNode is the same
67+
const auto heapNode = forward_heap.DeleteMinGetHeapNode();
6768

6869
const auto scaled_weight =
6970
static_cast<EdgeWeight>((heapNode.weight + min_edge_offset) / (1. + VIAPATH_EPSILON));
@@ -76,7 +77,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
7677

7778
search_space.emplace_back(heapNode.data.parent, heapNode.node);
7879

79-
const auto reverseHeapNode= reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
80+
const auto reverseHeapNode = reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
8081
if (reverseHeapNode)
8182
{
8283
search_space_intersection.emplace_back(heapNode.node);
@@ -114,7 +115,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
114115
BOOST_ASSERT(edge_weight > 0);
115116
const EdgeWeight to_weight = heapNode.weight + edge_weight;
116117

117-
const auto toHeapNode= forward_heap.GetHeapNodeIfWasInserted(to);
118+
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
118119
// New Node discovered -> Add to Heap + Node Info Storage
119120
if (!toHeapNode)
120121
{
@@ -126,7 +127,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
126127
// new parent
127128
toHeapNode->data.parent = heapNode.node;
128129
// decreased weight
129-
toHeapNode->weight=to_weight;
130+
toHeapNode->weight = to_weight;
130131
forward_heap.DecreaseKey(*toHeapNode);
131132
}
132133
}
@@ -561,7 +562,7 @@ bool viaNodeCandidatePassesTTest(SearchEngineData<Algorithm> &engine_working_dat
561562
}
562563
return (upper_bound <= t_test_path_weight);
563564
}
564-
} // anon. namespace
565+
} // namespace
565566

566567
InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engine_working_data,
567568
const DataFacade<Algorithm> &facade,
@@ -856,4 +857,4 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engi
856857

857858
} // namespace routing_algorithms
858859
} // namespace engine
859-
} // namespace osrm}
860+
} // namespace osrm

src/engine/routing_algorithms/many_to_many_ch.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ inline bool addLoopWeight(const DataFacade<ch::Algorithm> &facade,
4545
}
4646

4747
template <bool DIRECTION>
48-
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
49-
const typename SearchEngineData<Algorithm>::ManyToManyQueryHeap::HeapNode& heapNode,
50-
typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &query_heap,
51-
const PhantomNode &)
48+
void relaxOutgoingEdges(
49+
const DataFacade<Algorithm> &facade,
50+
const typename SearchEngineData<Algorithm>::ManyToManyQueryHeap::HeapNode &heapNode,
51+
typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &query_heap,
52+
const PhantomNode &)
5253
{
5354
if (stallAtNode<DIRECTION>(facade, heapNode, query_heap))
5455
{
@@ -71,7 +72,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
7172
const auto to_duration = heapNode.data.duration + edge_duration;
7273
const auto to_distance = heapNode.data.distance + edge_distance;
7374

74-
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
75+
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
7576
// New Node discovered -> Add to Heap + Node Info Storage
7677
if (!toHeapNode)
7778
{
@@ -82,7 +83,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
8283
std::tie(toHeapNode->weight, toHeapNode->data.duration))
8384
{
8485
toHeapNode->data = {heapNode.node, to_duration, to_distance};
85-
toHeapNode->weight=to_weight;
86+
toHeapNode->weight = to_weight;
8687
query_heap.DecreaseKey(*toHeapNode);
8788
}
8889
}
@@ -100,8 +101,9 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
100101
std::vector<NodeID> &middle_nodes_table,
101102
const PhantomNode &phantom_node)
102103
{
103-
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is the same
104-
const auto heapNode=query_heap.DeleteMinGetHeapNode();
104+
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is
105+
// the same
106+
const auto heapNode = query_heap.DeleteMinGetHeapNode();
105107

106108
// Check if each encountered node has an entry
107109
const auto &bucket_list = std::equal_range(search_space_with_buckets.begin(),
@@ -149,8 +151,7 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
149151
}
150152
}
151153

152-
relaxOutgoingEdges<FORWARD_DIRECTION>(
153-
facade, heapNode, query_heap, phantom_node);
154+
relaxOutgoingEdges<FORWARD_DIRECTION>(facade, heapNode, query_heap, phantom_node);
154155
}
155156

156157
void backwardRoutingStep(const DataFacade<Algorithm> &facade,
@@ -159,15 +160,19 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
159160
std::vector<NodeBucket> &search_space_with_buckets,
160161
const PhantomNode &phantom_node)
161162
{
162-
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if toHeapNode is the same
163-
const auto heapNode=query_heap.DeleteMinGetHeapNode();
163+
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if
164+
// toHeapNode is the same
165+
const auto heapNode = query_heap.DeleteMinGetHeapNode();
164166

165167
// Store settled nodes in search space bucket
166-
search_space_with_buckets.emplace_back(
167-
heapNode.node, heapNode.data.parent, column_index, heapNode.weight, heapNode.data.duration, heapNode.data.distance);
168-
169-
relaxOutgoingEdges<REVERSE_DIRECTION>(
170-
facade, heapNode, query_heap, phantom_node);
168+
search_space_with_buckets.emplace_back(heapNode.node,
169+
heapNode.data.parent,
170+
column_index,
171+
heapNode.weight,
172+
heapNode.data.duration,
173+
heapNode.data.distance);
174+
175+
relaxOutgoingEdges<REVERSE_DIRECTION>(facade, heapNode, query_heap, phantom_node);
171176
}
172177

173178
} // namespace ch

0 commit comments

Comments
 (0)