Skip to content

Commit

Permalink
Change edge_id to from_clique_arc in MultiLayerDijkstraHeapData
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Mar 17, 2017
1 parent f1b88ad commit 79ef204
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
3 changes: 3 additions & 0 deletions include/engine/datafacade/algorithm_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ template <> class AlgorithmDataFacade<algorithm::MLD>
virtual const partition::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;

virtual const partition::CellStorageView &GetCellStorage() const = 0;

// searches for a specific edge
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,12 @@ class ContiguousInternalMemoryDataFacade<algorithm::MLD>
{
return m_query_graph->GetAdjacentEdgeRange(node);
}

// searches for a specific edge
EdgeID FindEdge(const NodeID from, const NodeID to) const override final
{
return m_query_graph->FindEdge(from, to);
}
};
}
}
Expand Down
33 changes: 14 additions & 19 deletions include/engine/routing_algorithms/routing_base_mld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm:
}

const auto level = getNodeQureyLevel(partition, node, args...);
const auto &node_data = forward_heap.GetData(node);
const auto check_overlay_edges =
(level >= 1) && // only if at least the first level and
(node_data.parent == node || // is the first point of the path
node_data.edge_id != SPECIAL_EDGEID); // or an overlay entreé point

if (check_overlay_edges)
if (level >= 1 && !forward_heap.GetData(node).from_clique_arc)
{
if (DIRECTION == FORWARD_DIRECTION)
{
Expand All @@ -109,11 +104,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm:
const EdgeWeight to_weight = weight + shortcut_weight;
if (!forward_heap.WasInserted(to))
{
forward_heap.Insert(to, to_weight, {node});
forward_heap.Insert(to, to_weight, {node, true});
}
else if (to_weight < forward_heap.GetKey(to))
{
forward_heap.GetData(to) = {node};
forward_heap.GetData(to) = {node, true};
forward_heap.DecreaseKey(to, to_weight);
}
}
Expand All @@ -134,11 +129,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm:
const EdgeWeight to_weight = weight + shortcut_weight;
if (!forward_heap.WasInserted(to))
{
forward_heap.Insert(to, to_weight, {node});
forward_heap.Insert(to, to_weight, {node, true});
}
else if (to_weight < forward_heap.GetKey(to))
{
forward_heap.GetData(to) = {node};
forward_heap.GetData(to) = {node, true};
forward_heap.DecreaseKey(to, to_weight);
}
}
Expand All @@ -163,11 +158,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm:

if (!forward_heap.WasInserted(to))
{
forward_heap.Insert(to, to_weight, {node, edge});
forward_heap.Insert(to, to_weight, {node, false});
}
else if (to_weight < forward_heap.GetKey(to))
{
forward_heap.GetData(to) = {node, edge};
forward_heap.GetData(to) = {node, false};
forward_heap.DecreaseKey(to, to_weight);
}
}
Expand Down Expand Up @@ -220,12 +215,12 @@ search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &fac
}

// Get packed path as edges {from node ID, to node ID, edge ID}
std::vector<std::tuple<NodeID, NodeID, EdgeID>> packed_path;
std::vector<std::tuple<NodeID, NodeID, bool>> packed_path;
NodeID current_node = middle, parent_node = forward_heap.GetData(middle).parent;
while (parent_node != current_node)
{
const auto &data = forward_heap.GetData(current_node);
packed_path.push_back(std::make_tuple(parent_node, current_node, data.edge_id));
packed_path.push_back(std::make_tuple(parent_node, current_node, data.from_clique_arc));
current_node = parent_node;
parent_node = forward_heap.GetData(parent_node).parent;
}
Expand All @@ -236,7 +231,7 @@ search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &fac
while (parent_node != current_node)
{
const auto &data = reverse_heap.GetData(current_node);
packed_path.push_back(std::make_tuple(current_node, parent_node, data.edge_id));
packed_path.push_back(std::make_tuple(current_node, parent_node, data.from_clique_arc));
current_node = parent_node;
parent_node = reverse_heap.GetData(parent_node).parent;
}
Expand All @@ -248,11 +243,11 @@ search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &fac
for (auto const &packed_edge : packed_path)
{
NodeID source, target;
EdgeID edge_id;
std::tie(source, target, edge_id) = packed_edge;
if (edge_id != SPECIAL_EDGEID)
bool overlay_edge;
std::tie(source, target, overlay_edge) = packed_edge;
if (!overlay_edge)
{ // a base graph edge
unpacked_path.push_back(edge_id);
unpacked_path.push_back(facade.FindEdge(source, target));
}
else
{ // an overlay graph edge
Expand Down
6 changes: 3 additions & 3 deletions include/engine/search_engine_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct ManyToManyHeapData : HeapData

struct MultiLayerDijkstraHeapData : HeapData
{
EdgeID edge_id; // edge id if parent -> node is a boundary edge
MultiLayerDijkstraHeapData(NodeID p) : HeapData(p), edge_id(SPECIAL_EDGEID) {}
MultiLayerDijkstraHeapData(NodeID p, EdgeID edge_id) : HeapData(p), edge_id(edge_id) {}
bool from_clique_arc;
MultiLayerDijkstraHeapData(NodeID p) : HeapData(p), from_clique_arc(false) {}
MultiLayerDijkstraHeapData(NodeID p, bool from) : HeapData(p), from_clique_arc(from) {}
};

struct SearchEngineData
Expand Down

0 comments on commit 79ef204

Please sign in to comment.