Skip to content

Commit 404c275

Browse files
TheMarexPatrick Niklaus
authored andcommitted
Add a specilization for contraction without exclude flags
This saves about 10% overhead and avoids contraction changes to previous releases.
1 parent 088d4ed commit 404c275

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

include/contractor/contract_excludable_graph.hpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@ namespace osrm
1212
namespace contractor
1313
{
1414

15-
using GraphFilterAndCore = std::tuple<QueryGraph, std::vector<std::vector<bool>>>;
15+
using GraphAndFilter = std::tuple<QueryGraph, std::vector<std::vector<bool>>>;
16+
17+
inline auto contractFullGraph(ContractorGraph contractor_graph,
18+
std::vector<EdgeWeight> node_weights)
19+
{
20+
auto num_nodes = contractor_graph.GetNumberOfNodes();
21+
contractGraph(contractor_graph, node_weights);
22+
23+
auto edges = toEdges<QueryEdge>(std::move(contractor_graph));
24+
std::vector<bool> edge_filter(edges.size(), true);
25+
26+
return GraphAndFilter{QueryGraph{num_nodes, std::move(edges)}, {std::move(edge_filter)}};
27+
}
1628

1729
inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
1830
std::vector<EdgeWeight> node_weights,
1931
const std::vector<std::vector<bool>> &filters)
2032
{
33+
if (filters.size() == 1)
34+
{
35+
if (std::all_of(filters.front().begin(), filters.front().end(), [](auto v) { return v; }))
36+
{
37+
return contractFullGraph(std::move(contractor_graph_), std::move(node_weights));
38+
}
39+
}
40+
2141
auto num_nodes = contractor_graph_.GetNumberOfNodes();
2242
ContractedEdgeContainer edge_container;
2343
ContractorGraph shared_core_graph;
@@ -64,8 +84,8 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
6484
edge_container.Merge(toEdges<QueryEdge>(std::move(filtered_core_graph)));
6585
}
6686

67-
return GraphFilterAndCore{QueryGraph{num_nodes, std::move(edge_container.edges)},
68-
edge_container.MakeEdgeFilters()};
87+
return GraphAndFilter{QueryGraph{num_nodes, std::move(edge_container.edges)},
88+
edge_container.MakeEdgeFilters()};
6989
}
7090
}
7191
}

0 commit comments

Comments
 (0)