Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug-fix: invalid contract node #7066

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/contractor/contractor_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace osrm::contractor

void search(ContractorHeap &heap,
const ContractorGraph &graph,
const std::vector<bool> &contractable,
const unsigned number_of_targets,
const int node_limit,
const EdgeWeight weight_limit,
Expand Down
7 changes: 6 additions & 1 deletion src/contractor/contractor_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace
{
void relaxNode(ContractorHeap &heap,
const ContractorGraph &graph,
const std::vector<bool> &contractable,
const NodeID node,
const EdgeWeight node_weight,
const NodeID forbidden_node)
Expand All @@ -34,6 +35,9 @@ void relaxNode(ContractorHeap &heap,
// New Node discovered -> Add to Heap + Node Info Storage
if (!toHeapNode)
{
if (!contractable[to]) {
continue;
}
heap.Insert(to, to_weight, ContractorHeapData{current_hop, false});
}
// Found a shorter Path -> Update weight
Expand All @@ -49,6 +53,7 @@ void relaxNode(ContractorHeap &heap,

void search(ContractorHeap &heap,
const ContractorGraph &graph,
const std::vector<bool> &contractable,
const unsigned number_of_targets,
const int node_limit,
const EdgeWeight weight_limit,
Expand Down Expand Up @@ -80,7 +85,7 @@ void search(ContractorHeap &heap,
}
}

relaxNode(heap, graph, node, node_weight, forbidden_node);
relaxNode(heap, graph, contractable, node, node_weight, forbidden_node);
}
}
} // namespace osrm::contractor
21 changes: 12 additions & 9 deletions src/contractor/graph_contractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void ContractNode(ContractorThreadData *data,
const ContractorGraph &graph,
const NodeID node,
std::vector<EdgeWeight> &node_weights,
const std::vector<bool> &contractable,
ContractionStats *stats = nullptr)
{
auto &heap = data->heap;
Expand Down Expand Up @@ -245,12 +246,12 @@ void ContractNode(ContractorThreadData *data,
if (RUNSIMULATION)
{
const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000;
search(heap, graph, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, max_weight, node);
search(heap, graph, contractable, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, max_weight, node);
}
else
{
const int constexpr FULL_SEARCH_SPACE_SIZE = 2000;
search(heap, graph, number_of_targets, FULL_SEARCH_SPACE_SIZE, max_weight, node);
search(heap, graph, contractable, number_of_targets, FULL_SEARCH_SPACE_SIZE, max_weight, node);
}
for (auto out_edge : graph.GetAdjacentEdgeRange(node))
{
Expand Down Expand Up @@ -344,18 +345,20 @@ void ContractNode(ContractorThreadData *data,
void ContractNode(ContractorThreadData *data,
const ContractorGraph &graph,
const NodeID node,
std::vector<EdgeWeight> &node_weights)
std::vector<EdgeWeight> &node_weights,
const std::vector<bool> &contractable)
{
ContractNode<false>(data, graph, node, node_weights, nullptr);
ContractNode<false>(data, graph, node, node_weights, contractable, nullptr);
}

ContractionStats SimulateNodeContraction(ContractorThreadData *data,
const ContractorGraph &graph,
const NodeID node,
std::vector<EdgeWeight> &node_weights)
std::vector<EdgeWeight> &node_weights,
const std::vector<bool> &contractable)
{
ContractionStats stats;
ContractNode<true>(data, graph, node, node_weights, &stats);
ContractNode<true>(data, graph, node, node_weights, contractable, &stats);
return stats;
}

Expand Down Expand Up @@ -487,7 +490,7 @@ bool UpdateNodeNeighbours(ContractorNodeData &node_data,
if (node_data.contractable[u])
{
node_data.priorities[u] = EvaluateNodePriority(
SimulateNodeContraction(data, graph, u, node_data.weights), node_data.depths[u]);
SimulateNodeContraction(data, graph, u, node_data.weights, node_data.contractable), node_data.depths[u]);
}
}
return true;
Expand Down Expand Up @@ -627,7 +630,7 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
auto node = remaining_nodes[x].id;
BOOST_ASSERT(node_data.contractable[node]);
node_data.priorities[node] = EvaluateNodePriority(
SimulateNodeContraction(data, graph, node, node_data.weights),
SimulateNodeContraction(data, graph, node, node_data.weights, node_data.contractable),
node_data.depths[node]);
}
});
Expand Down Expand Up @@ -688,7 +691,7 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
for (auto position = range.begin(), end = range.end(); position != end; ++position)
{
const NodeID node = remaining_nodes[position].id;
ContractNode(data, graph, node, node_data.weights);
ContractNode(data, graph, node, node_data.weights, node_data.contractable);
}
});

Expand Down