Don't scan back clique arcs
This commit is contained in:
parent
a3621f3655
commit
721f319909
@ -30,7 +30,7 @@ class CellCustomizer
|
||||
{
|
||||
std::unordered_set<NodeID> destinations_set(destinations.begin(), destinations.end());
|
||||
Heap heap(graph.GetNumberOfNodes());
|
||||
heap.Insert(source, 0, {});
|
||||
heap.Insert(source, 0, {false});
|
||||
|
||||
// explore search space
|
||||
while (!heap.Empty() && !destinations_set.empty())
|
||||
@ -75,6 +75,7 @@ class CellCustomizer
|
||||
private:
|
||||
struct HeapData
|
||||
{
|
||||
bool from_clique;
|
||||
};
|
||||
using Heap = util::
|
||||
BinaryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
|
||||
@ -88,7 +89,18 @@ class CellCustomizer
|
||||
NodeID node,
|
||||
EdgeWeight weight) const
|
||||
{
|
||||
BOOST_ASSERT(heap.WasInserted(node));
|
||||
|
||||
if (!first_level)
|
||||
{
|
||||
// if we reaches this node from a clique arc we don't need to scan
|
||||
// the clique arcs again because of the triangle inequality
|
||||
//
|
||||
// d(parent, node) + d(node, v) >= d(parent, v)
|
||||
//
|
||||
// And if there is a path (parent, node, v) there must also be a
|
||||
// clique arc (parent, v) with d(parent, v).
|
||||
if (!heap.GetData(node).from_clique)
|
||||
{
|
||||
// Relax sub-cell nodes
|
||||
auto subcell_id = partition.GetCell(level - 1, node);
|
||||
@ -102,17 +114,19 @@ class CellCustomizer
|
||||
const EdgeWeight to_weight = subcell_weight + weight;
|
||||
if (!heap.WasInserted(to))
|
||||
{
|
||||
heap.Insert(to, to_weight, {});
|
||||
heap.Insert(to, to_weight, {true});
|
||||
}
|
||||
else if (to_weight < heap.GetKey(to))
|
||||
{
|
||||
heap.DecreaseKey(to, to_weight);
|
||||
heap.GetData(to).from_clique = true;
|
||||
}
|
||||
}
|
||||
|
||||
++subcell_destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Relax base graph edges if a sub-cell border edge
|
||||
for (auto edge : graph.GetInternalEdgeRange(level, node))
|
||||
@ -126,11 +140,12 @@ class CellCustomizer
|
||||
const EdgeWeight to_weight = data.weight + weight;
|
||||
if (!heap.WasInserted(to))
|
||||
{
|
||||
heap.Insert(to, to_weight, {});
|
||||
heap.Insert(to, to_weight, {false});
|
||||
}
|
||||
else if (to_weight < heap.GetKey(to))
|
||||
{
|
||||
heap.DecreaseKey(to, to_weight);
|
||||
heap.GetData(to).from_clique = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user