Implement exclude flags on CH using shared core
The core is fully contracted for each exclude flag and stored in a merged graph data structure.
This commit is contained in:
committed by
Patrick Niklaus
parent
4b75cb8b0e
commit
61c430c098
@@ -1,6 +1,8 @@
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "../common/range_tools.hpp"
|
||||
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@@ -120,4 +122,41 @@ BOOST_AUTO_TEST_CASE(renumber_test)
|
||||
BOOST_CHECK_EQUAL(simple_graph.GetEdgeData(eit).id, 2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(filter_test)
|
||||
{
|
||||
/*
|
||||
* (0) -1-> (1)
|
||||
* ^ ^ ^
|
||||
* 2 5 1
|
||||
* | | |
|
||||
* (3) -3-> (4)
|
||||
* <-4-
|
||||
*/
|
||||
std::vector<TestInputEdge> input_edges = {TestInputEdge{0, 1, TestData{1}},
|
||||
TestInputEdge{3, 0, TestData{2}},
|
||||
TestInputEdge{3, 0, TestData{5}},
|
||||
TestInputEdge{3, 4, TestData{3}},
|
||||
TestInputEdge{4, 1, TestData{1}},
|
||||
TestInputEdge{4, 3, TestData{4}}};
|
||||
TestDynamicGraph simple_graph(5, input_edges);
|
||||
|
||||
// only keep 0, 1, 4 -> filter out all edges from/to 3
|
||||
auto filtered_simple_graph =
|
||||
simple_graph.Filter([](const NodeID node) { return node == 0 || node == 1 || node == 4; });
|
||||
|
||||
REQUIRE_SIZE_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(0), 1);
|
||||
CHECK_EQUAL_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(0),
|
||||
filtered_simple_graph.FindEdge(0, 1));
|
||||
|
||||
REQUIRE_SIZE_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(1), 0);
|
||||
|
||||
REQUIRE_SIZE_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(2), 0);
|
||||
|
||||
REQUIRE_SIZE_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(3), 0);
|
||||
|
||||
REQUIRE_SIZE_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(4), 1);
|
||||
CHECK_EQUAL_RANGE(filtered_simple_graph.GetAdjacentEdgeRange(4),
|
||||
filtered_simple_graph.FindEdge(4, 1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "util/filtered_integer_range.hpp"
|
||||
|
||||
#include "../common/range_tools.hpp"
|
||||
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(bit_range_test)
|
||||
|
||||
using namespace osrm;
|
||||
using namespace osrm::util;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(filtered_irange_test)
|
||||
{
|
||||
std::vector<bool> filter = {// 0 1 2 3 4 5
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false};
|
||||
|
||||
CHECK_EQUAL_RANGE(filtered_irange<std::uint8_t>(0, 2, filter), 0);
|
||||
CHECK_EQUAL_RANGE(filtered_irange<std::uint8_t>(1, 4, filter), 3);
|
||||
CHECK_EQUAL_RANGE(filtered_irange<std::uint8_t>(1, 5, filter), 3, 4);
|
||||
CHECK_EQUAL_RANGE(filtered_irange<std::uint8_t>(0, 6, filter), 0, 3, 4);
|
||||
|
||||
auto empty_1 = filtered_irange<std::uint8_t>(1, 3, filter);
|
||||
auto empty_2 = filtered_irange<std::uint8_t>(3, 3, filter);
|
||||
auto empty_3 = filtered_irange<std::uint8_t>(4, 4, filter);
|
||||
auto empty_4 = filtered_irange<std::uint8_t>(5, 5, filter);
|
||||
BOOST_CHECK(empty_1.begin() == empty_1.end());
|
||||
BOOST_CHECK(empty_2.begin() == empty_2.end());
|
||||
BOOST_CHECK(empty_3.begin() == empty_3.end());
|
||||
BOOST_CHECK(empty_4.begin() == empty_4.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user