format code
This commit is contained in:
@@ -24,7 +24,7 @@ namespace ch
|
||||
// Stalling
|
||||
template <bool DIRECTION, typename HeapT>
|
||||
bool stallAtNode(const DataFacade<Algorithm> &facade,
|
||||
const typename HeapT::HeapNode& heapNode,
|
||||
const typename HeapT::HeapNode &heapNode,
|
||||
const HeapT &query_heap)
|
||||
{
|
||||
for (auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
|
||||
@@ -35,7 +35,7 @@ bool stallAtNode(const DataFacade<Algorithm> &facade,
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
|
||||
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
|
||||
if (toHeapNode)
|
||||
{
|
||||
if (toHeapNode->weight + edge_weight < heapNode.weight)
|
||||
@@ -50,7 +50,7 @@ bool stallAtNode(const DataFacade<Algorithm> &facade,
|
||||
|
||||
template <bool DIRECTION>
|
||||
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
const SearchEngineData<Algorithm>::QueryHeap::HeapNode& heapNode,
|
||||
const SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
|
||||
SearchEngineData<Algorithm>::QueryHeap &heap)
|
||||
{
|
||||
for (const auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
|
||||
@@ -75,7 +75,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
{
|
||||
// new parent
|
||||
toHeapNode->data.parent = heapNode.node;
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
const std::vector<std::size_t> &phantom_indices)
|
||||
{
|
||||
auto min_level = [&partition, node](const PhantomNode &phantom_node) {
|
||||
|
||||
const auto &forward_segment = phantom_node.forward_segment_id;
|
||||
const auto forward_level =
|
||||
forward_segment.enabled ? partition.GetHighestDifferentLevel(node, forward_segment.id)
|
||||
@@ -120,7 +119,7 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Heaps only record for each node its predecessor ("parent") on the shortest path.
|
||||
// For re-constructing the actual path we need to trace back all parent "pointers".
|
||||
@@ -229,7 +228,7 @@ retrievePackedPathFromHeap(const SearchEngineData<Algorithm>::QueryHeap &forward
|
||||
template <bool DIRECTION, typename Algorithm, typename... Args>
|
||||
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode& heapNode,
|
||||
const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
|
||||
Args... args)
|
||||
{
|
||||
const auto &partition = facade.GetMultiLevelPartition();
|
||||
@@ -243,7 +242,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
if (DIRECTION == FORWARD_DIRECTION)
|
||||
{
|
||||
// Shortcuts in forward direction
|
||||
const auto &cell = cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
|
||||
const auto &cell =
|
||||
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
|
||||
auto destination = cell.GetDestinationNodes().begin();
|
||||
for (auto shortcut_weight : cell.GetOutWeight(heapNode.node))
|
||||
{
|
||||
@@ -262,7 +262,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
else if (to_weight < toHeapNode->weight)
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, true};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
forward_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
else
|
||||
{
|
||||
// Shortcuts in backward direction
|
||||
const auto &cell = cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
|
||||
const auto &cell =
|
||||
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
|
||||
auto source = cell.GetSourceNodes().begin();
|
||||
for (auto shortcut_weight : cell.GetInWeight(heapNode.node))
|
||||
{
|
||||
@@ -291,7 +292,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
else if (to_weight < toHeapNode->weight)
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, true};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
forward_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -328,8 +329,8 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
}
|
||||
else if (to_weight < toHeapNode->weight)
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, false};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->data = {heapNode.node, false};
|
||||
toHeapNode->weight = to_weight;
|
||||
forward_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-16
@@ -2,8 +2,8 @@
|
||||
#define OSRM_UTIL_QUERY_HEAP_HPP
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/heap/d_ary_heap.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
@@ -196,12 +196,11 @@ template <typename NodeID,
|
||||
class QueryHeap
|
||||
{
|
||||
private:
|
||||
|
||||
using HeapData = std::pair<Weight, Key>;
|
||||
using HeapContainer = boost::heap::d_ary_heap<HeapData,
|
||||
boost::heap::arity<4>,
|
||||
boost::heap::mutable_<true>,
|
||||
boost::heap::compare<std::greater<HeapData>>>;
|
||||
boost::heap::arity<4>,
|
||||
boost::heap::mutable_<true>,
|
||||
boost::heap::compare<std::greater<HeapData>>>;
|
||||
using HeapHandle = typename HeapContainer::handle_type;
|
||||
|
||||
public:
|
||||
@@ -248,7 +247,7 @@ class QueryHeap
|
||||
return inserted_nodes[index].data;
|
||||
}
|
||||
|
||||
HeapNode& getHeapNode(NodeID node)
|
||||
HeapNode &getHeapNode(NodeID node)
|
||||
{
|
||||
const auto index = node_index.peek_index(node);
|
||||
BOOST_ASSERT((int)index >= 0 && (int)index < (int)inserted_nodes.size());
|
||||
@@ -294,28 +293,28 @@ class QueryHeap
|
||||
return inserted_nodes[index].node == node;
|
||||
}
|
||||
|
||||
boost::optional<HeapNode&> GetHeapNodeIfWasInserted(const NodeID node)
|
||||
boost::optional<HeapNode &> GetHeapNodeIfWasInserted(const NodeID node)
|
||||
{
|
||||
const auto index = node_index.peek_index(node);
|
||||
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) || inserted_nodes[index].node!=node)
|
||||
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) ||
|
||||
inserted_nodes[index].node != node)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return inserted_nodes[index];
|
||||
}
|
||||
|
||||
boost::optional<const HeapNode&> GetHeapNodeIfWasInserted(const NodeID node) const
|
||||
boost::optional<const HeapNode &> GetHeapNodeIfWasInserted(const NodeID node) const
|
||||
{
|
||||
const auto index = node_index.peek_index(node);
|
||||
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) || inserted_nodes[index].node!=node)
|
||||
if (index >= static_cast<decltype(index)>(inserted_nodes.size()) ||
|
||||
inserted_nodes[index].node != node)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return inserted_nodes[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
NodeID Min() const
|
||||
{
|
||||
BOOST_ASSERT(!heap.empty());
|
||||
@@ -337,7 +336,7 @@ class QueryHeap
|
||||
return inserted_nodes[removedIndex].node;
|
||||
}
|
||||
|
||||
HeapNode& DeleteMinGetHeapNode()
|
||||
HeapNode &DeleteMinGetHeapNode()
|
||||
{
|
||||
BOOST_ASSERT(!heap.empty());
|
||||
const Key removedIndex = heap.top().second;
|
||||
@@ -364,7 +363,7 @@ class QueryHeap
|
||||
heap.increase(reference.handle, std::make_pair(weight, index));
|
||||
}
|
||||
|
||||
void DecreaseKey(const HeapNode& heapNode)
|
||||
void DecreaseKey(const HeapNode &heapNode)
|
||||
{
|
||||
BOOST_ASSERT(!WasRemoved(heapNode.node));
|
||||
heap.increase(heapNode.handle, std::make_pair(heapNode.weight, (*heapNode.handle).second));
|
||||
@@ -375,7 +374,7 @@ class QueryHeap
|
||||
HeapContainer heap;
|
||||
IndexStorage node_index;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_UTIL_QUERY_HEAP_HPP
|
||||
|
||||
Reference in New Issue
Block a user