Make edge metrics strongly typed (#6421)
This change takes the existing typedefs for weight, duration and distance, and makes them proper types, using the existing Alias functionality. Primarily this is to prevent bugs where the metrics are switched, but it also adds additional documentation. For example, it now makes it clear (despite the naming of variables) that most of the trip algorithm is running on the duration metric. I've not made any changes to the casts performed between metrics and numeric types, they now just more explicit.
This commit is contained in:
@@ -37,31 +37,31 @@ BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_graph)
|
||||
ContractedEdgeContainer container;
|
||||
|
||||
std::vector<QueryEdge> edges;
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 3, 3, 6, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 3, 3, 6, false, true}});
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, {3}, {3}, {6}, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, {3}, {3}, {6}, false, true}});
|
||||
container.Insert(edges);
|
||||
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 12, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 12, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, {12}, {12}, {24}, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, {12}, {12}, {24}, false, true}});
|
||||
container.Merge(edges);
|
||||
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, {3}, {3}, {6}, true, false}});
|
||||
container.Merge(edges);
|
||||
|
||||
std::vector<QueryEdge> reference_edges;
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 3, 3, 6, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 3, 3, 6, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, {3}, {3}, {6}, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, {12}, {12}, {24}, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, {3}, {3}, {6}, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, {12}, {12}, {24}, false, true}});
|
||||
CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
|
||||
auto filters = container.MakeEdgeFilters();
|
||||
@@ -79,22 +79,22 @@ BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_disjoint_graph)
|
||||
ContractedEdgeContainer container;
|
||||
|
||||
std::vector<QueryEdge> edges;
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 12, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 12, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, {3}, {3}, {6}, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, {12}, {12}, {24}, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, {12}, {12}, {24}, false, true}});
|
||||
container.Merge(edges);
|
||||
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, 3, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, {3}, {3}, {6}, true, false}});
|
||||
container.Merge(edges);
|
||||
|
||||
std::vector<QueryEdge> reference_edges;
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, {3}, {3}, {6}, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, {12}, {12}, {24}, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, {12}, {12}, {24}, false, true}});
|
||||
CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
|
||||
auto filters = container.MakeEdgeFilters();
|
||||
|
||||
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(contract_graph)
|
||||
auto reference_graph = makeGraph(edges);
|
||||
|
||||
auto contracted_graph = reference_graph;
|
||||
std::vector<bool> core = contractGraph(contracted_graph, {1, 1, 1, 1, 1, 1});
|
||||
std::vector<bool> core = contractGraph(contracted_graph, {{1}, {1}, {1}, {1}, {1}, {1}});
|
||||
|
||||
// This contraction order is dependent on the priority caculation in the contractor
|
||||
// but deterministic for the same graph.
|
||||
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(contract_graph)
|
||||
reference_graph.DeleteEdgesTo(1, 3);
|
||||
reference_graph.DeleteEdgesTo(4, 3);
|
||||
// Insert shortcut
|
||||
reference_graph.InsertEdge(4, 1, {2, 4, 1.0, 3, 0, true, true, false});
|
||||
reference_graph.InsertEdge(4, 1, {{2}, {4}, {1.0}, 3, 0, true, true, false});
|
||||
|
||||
/* After contracting 4:
|
||||
*
|
||||
|
||||
@@ -27,12 +27,12 @@ inline contractor::ContractorGraph makeGraph(const std::vector<TestEdge> &edges)
|
||||
start,
|
||||
target,
|
||||
contractor::ContractorEdgeData{
|
||||
weight, duration, distance, id++, 0, false, true, false}});
|
||||
{weight}, {duration}, {distance}, id++, 0, false, true, false}});
|
||||
input_edges.push_back(contractor::ContractorEdge{
|
||||
target,
|
||||
start,
|
||||
contractor::ContractorEdgeData{
|
||||
weight, duration, distance, id++, 0, false, false, true}});
|
||||
{weight}, {duration}, {distance}, id++, 0, false, false, true}});
|
||||
}
|
||||
std::sort(input_edges.begin(), input_edges.end());
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ auto makeGraph(const MultiLevelPartition &mlp, const std::vector<MockEdge> &mock
|
||||
edges.push_back(Edge{m.start,
|
||||
m.target,
|
||||
m.weight,
|
||||
2 * m.weight,
|
||||
static_cast<EdgeDistance>(1.0),
|
||||
EdgeDuration{2} * alias_cast<EdgeDuration>(m.weight),
|
||||
EdgeDistance{1.0},
|
||||
true,
|
||||
false});
|
||||
edges.push_back(Edge{m.target,
|
||||
m.start,
|
||||
m.weight,
|
||||
2 * m.weight,
|
||||
static_cast<EdgeDistance>(1.0),
|
||||
EdgeDuration{2} * alias_cast<EdgeDuration>(m.weight),
|
||||
EdgeDistance{1.0},
|
||||
false,
|
||||
true});
|
||||
}
|
||||
@@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(two_level_test)
|
||||
|
||||
BOOST_REQUIRE_EQUAL(mlp.GetNumberOfLevels(), 2);
|
||||
|
||||
std::vector<MockEdge> edges = {{0, 1, 1}, {0, 2, 1}, {2, 3, 1}, {3, 1, 1}, {3, 2, 1}};
|
||||
std::vector<MockEdge> edges = {{0, 1, {1}}, {0, 2, {1}}, {2, 3, {1}}, {3, 1, {1}}, {3, 2, {1}}};
|
||||
|
||||
auto graph = makeGraph(mlp, edges);
|
||||
std::vector<bool> node_filter(graph.GetNumberOfNodes(), true);
|
||||
@@ -106,17 +106,17 @@ BOOST_AUTO_TEST_CASE(two_level_test)
|
||||
|
||||
// cell 0
|
||||
// check row source -> destination
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(0), 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(0), EdgeWeight{1});
|
||||
// check column destination -> source
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(1), 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(1), EdgeWeight{1});
|
||||
|
||||
// cell 1
|
||||
// check row source -> destination
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(2), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(3), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(2), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(3), EdgeWeight{1}, EdgeWeight{0});
|
||||
// check column destination -> source
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(2), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(3), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(2), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(3), EdgeWeight{1}, EdgeWeight{0});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(four_levels_test)
|
||||
@@ -130,27 +130,27 @@ BOOST_AUTO_TEST_CASE(four_levels_test)
|
||||
BOOST_REQUIRE_EQUAL(mlp.GetNumberOfLevels(), 4);
|
||||
|
||||
std::vector<MockEdge> edges = {
|
||||
{0, 1, 1}, // cell (0, 0, 0)
|
||||
{0, 2, 1}, {3, 1, 1}, {3, 2, 1},
|
||||
{0, 1, {1}}, // cell (0, 0, 0)
|
||||
{0, 2, {1}}, {3, 1, {1}}, {3, 2, {1}},
|
||||
|
||||
{4, 5, 1}, // cell (1, 0, 0)
|
||||
{4, 6, 1}, {4, 7, 1}, {5, 4, 1}, {5, 6, 1}, {5, 7, 1}, {6, 4, 1},
|
||||
{6, 5, 1}, {6, 7, 1}, {7, 4, 1}, {7, 5, 1}, {7, 6, 1},
|
||||
{4, 5, {1}}, // cell (1, 0, 0)
|
||||
{4, 6, {1}}, {4, 7, {1}}, {5, 4, {1}}, {5, 6, {1}}, {5, 7, {1}}, {6, 4, {1}},
|
||||
{6, 5, {1}}, {6, 7, {1}}, {7, 4, {1}}, {7, 5, {1}}, {7, 6, {1}},
|
||||
|
||||
{9, 11, 1}, // cell (2, 1, 0)
|
||||
{10, 8, 1}, {11, 10, 1},
|
||||
{9, 11, {1}}, // cell (2, 1, 0)
|
||||
{10, 8, {1}}, {11, 10, {1}},
|
||||
|
||||
{13, 12, 10}, // cell (3, 1, 0)
|
||||
{15, 14, 1},
|
||||
{13, 12, {10}}, // cell (3, 1, 0)
|
||||
{15, 14, {1}},
|
||||
|
||||
{2, 4, 1}, // edge between cells (0, 0, 0) -> (1, 0, 0)
|
||||
{5, 12, 1}, // edge between cells (1, 0, 0) -> (3, 1, 0)
|
||||
{8, 3, 1}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{9, 3, 1}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{12, 5, 1}, // edge between cells (3, 1, 0) -> (1, 0, 0)
|
||||
{13, 7, 1}, // edge between cells (3, 1, 0) -> (1, 0, 0)
|
||||
{14, 9, 1}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{14, 11, 1} // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{2, 4, {1}}, // edge between cells (0, 0, 0) -> (1, 0, 0)
|
||||
{5, 12, {1}}, // edge between cells (1, 0, 0) -> (3, 1, 0)
|
||||
{8, 3, {1}}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{9, 3, {1}}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{12, 5, {1}}, // edge between cells (3, 1, 0) -> (1, 0, 0)
|
||||
{13, 7, {1}}, // edge between cells (3, 1, 0) -> (1, 0, 0)
|
||||
{14, 9, {1}}, // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
{14, 11, {1}} // edge between cells (2, 1, 0) -> (0, 0, 0)
|
||||
};
|
||||
|
||||
auto graph = makeGraph(mlp, edges);
|
||||
@@ -238,48 +238,53 @@ BOOST_AUTO_TEST_CASE(four_levels_test)
|
||||
|
||||
// level 1
|
||||
// cell 0
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(3), 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(2), 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(3), EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(2), EdgeWeight{1});
|
||||
|
||||
// cell 1
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(4), 0, 1, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(5), 1, 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(7), 1, 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(4), 0, 1, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(5), 1, 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(7), 1, 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(4), EdgeWeight{0}, EdgeWeight{1}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(5), EdgeWeight{1}, EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(7), EdgeWeight{1}, EdgeWeight{1}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(4), EdgeWeight{0}, EdgeWeight{1}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(5), EdgeWeight{1}, EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(7), EdgeWeight{1}, EdgeWeight{1}, EdgeWeight{0});
|
||||
|
||||
// cell 2
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(9), 3, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(11), 2, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(8), 3, 2);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(11), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(9), EdgeWeight{3}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(11), EdgeWeight{2}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(8), EdgeWeight{3}, EdgeWeight{2});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(11), EdgeWeight{1}, EdgeWeight{0});
|
||||
|
||||
// cell 3
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetOutWeight(13), 10, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(12), 10);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetOutWeight(13), EdgeWeight{10}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(12), EdgeWeight{10});
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(14), INVALID_EDGE_WEIGHT);
|
||||
|
||||
// level 2
|
||||
// cell 0
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(3), 3, 3);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(5), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(7), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(5), 3, 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(7), 3, 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(3), EdgeWeight{3}, EdgeWeight{3});
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(5), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(7), EdgeWeight{1}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(5), EdgeWeight{3}, EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(7), EdgeWeight{3}, EdgeWeight{1}, EdgeWeight{0});
|
||||
|
||||
// cell 1
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(9), 3, 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(13), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, 10);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(8), 3, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(9), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(12), INVALID_EDGE_WEIGHT, 10);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(9), EdgeWeight{3}, EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(
|
||||
cell_2_1.GetOutWeight(13), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, EdgeWeight{10});
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(8), EdgeWeight{3}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(9), EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(12), INVALID_EDGE_WEIGHT, EdgeWeight{10});
|
||||
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutDuration(9), 6, 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutDuration(13), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, 20);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(8), 6, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(9), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(12), INVALID_EDGE_WEIGHT, 20);
|
||||
CHECK_EQUAL_RANGE(
|
||||
cell_2_1.GetOutDuration(9), EdgeDuration{6}, EdgeDuration{0}, INVALID_EDGE_DURATION);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutDuration(13),
|
||||
INVALID_EDGE_DURATION,
|
||||
INVALID_EDGE_DURATION,
|
||||
EdgeDuration{20});
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(8), EdgeDuration{6}, INVALID_EDGE_DURATION);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(9), EdgeDuration{0}, INVALID_EDGE_DURATION);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInDuration(12), INVALID_EDGE_DURATION, EdgeDuration{20});
|
||||
|
||||
CellStorage storage_rec(mlp, graph);
|
||||
auto metric_rec = storage_rec.MakeMetric();
|
||||
@@ -304,9 +309,10 @@ BOOST_AUTO_TEST_CASE(exclude_test)
|
||||
// 2 ----3 --- 4 --- 7
|
||||
// \__________/
|
||||
std::vector<MockEdge> edges = {
|
||||
{0, 1, 1}, {0, 2, 1}, {1, 0, 1}, {1, 2, 10}, {1, 3, 1}, {1, 5, 1}, {2, 0, 1}, {2, 1, 10},
|
||||
{2, 3, 1}, {2, 4, 1}, {3, 1, 1}, {3, 2, 1}, {3, 4, 1}, {4, 2, 1}, {4, 3, 1}, {4, 5, 1},
|
||||
{4, 7, 1}, {5, 1, 1}, {5, 4, 1}, {5, 6, 1}, {6, 5, 1}, {6, 7, 1}, {7, 4, 1}, {7, 6, 1},
|
||||
{0, 1, {1}}, {0, 2, {1}}, {1, 0, {1}}, {1, 2, {10}}, {1, 3, {1}}, {1, 5, {1}},
|
||||
{2, 0, {1}}, {2, 1, {10}}, {2, 3, {1}}, {2, 4, {1}}, {3, 1, {1}}, {3, 2, {1}},
|
||||
{3, 4, {1}}, {4, 2, {1}}, {4, 3, {1}}, {4, 5, {1}}, {4, 7, {1}}, {5, 1, {1}},
|
||||
{5, 4, {1}}, {5, 6, {1}}, {6, 5, {1}}, {6, 7, {1}}, {7, 4, {1}}, {7, 6, {1}},
|
||||
};
|
||||
|
||||
// node: 0 1 2 3 4 5 6 7
|
||||
@@ -367,20 +373,20 @@ BOOST_AUTO_TEST_CASE(exclude_test)
|
||||
REQUIRE_SIZE_RANGE(cell_1_3.GetInWeight(7), 2);
|
||||
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(0), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(1), INVALID_EDGE_WEIGHT, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetOutWeight(1), INVALID_EDGE_WEIGHT, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(0), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(1), INVALID_EDGE_WEIGHT, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(2), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_0.GetInWeight(1), INVALID_EDGE_WEIGHT, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(2), EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetOutWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(2), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(2), EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_1.GetInWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(5), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(6), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(5), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(6), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetOutWeight(4), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(5), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetOutWeight(6), EdgeWeight{1}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(5), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_1_2.GetInWeight(6), EdgeWeight{1}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetOutWeight(4), EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetOutWeight(7), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(4), 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(4), EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_1_3.GetInWeight(7), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
|
||||
auto cell_2_0 = storage.GetCell(metric, 2, 0);
|
||||
@@ -407,19 +413,19 @@ BOOST_AUTO_TEST_CASE(exclude_test)
|
||||
REQUIRE_SIZE_RANGE(cell_2_1.GetInWeight(4), 2);
|
||||
REQUIRE_SIZE_RANGE(cell_2_1.GetInWeight(5), 2);
|
||||
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(1), 0, 10, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(2), 10, 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(1), EdgeWeight{0}, EdgeWeight{10}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(2), EdgeWeight{10}, EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(
|
||||
cell_2_0.GetOutWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(1), 0, 10, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(2), 10, 0, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(1), EdgeWeight{0}, EdgeWeight{10}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(2), EdgeWeight{10}, EdgeWeight{0}, INVALID_EDGE_WEIGHT);
|
||||
CHECK_EQUAL_RANGE(
|
||||
cell_2_0.GetInWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT);
|
||||
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(4), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(5), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(4), 0, 1);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(5), 1, 0);
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(4), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(5), EdgeWeight{1}, EdgeWeight{0});
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(4), EdgeWeight{0}, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(cell_2_1.GetInWeight(5), EdgeWeight{1}, EdgeWeight{0});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -19,14 +19,14 @@ BOOST_AUTO_TEST_CASE(unchanged_collapse_route_result)
|
||||
PhantomNode target;
|
||||
source.forward_segment_id = {1, true};
|
||||
target.forward_segment_id = {6, true};
|
||||
PathData pathy{0, 2, 2, 3, 4, 5, 2, boost::none};
|
||||
PathData kathy{0, 1, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none};
|
||||
PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
InternalRouteResult one_leg_result;
|
||||
one_leg_result.unpacked_path_segments = {{pathy, kathy}};
|
||||
one_leg_result.leg_endpoints = {PhantomEndpoints{source, target}};
|
||||
one_leg_result.source_traversed_in_reverse = {true};
|
||||
one_leg_result.target_traversed_in_reverse = {true};
|
||||
one_leg_result.shortest_path_weight = 50;
|
||||
one_leg_result.shortest_path_weight = {50};
|
||||
|
||||
auto collapsed = CollapseInternalRouteResult(one_leg_result, {true, true});
|
||||
BOOST_CHECK_EQUAL(one_leg_result.unpacked_path_segments[0].front().turn_via_node,
|
||||
@@ -39,22 +39,26 @@ BOOST_AUTO_TEST_CASE(two_legs_to_one_leg)
|
||||
{
|
||||
// from_edge_based_node, turn_via_node, weight_until_turn, weight_of_turn,
|
||||
// duration_until_turn, duration_of_turn, datasource_id, turn_edge
|
||||
PathData pathy{0, 2, 2, 3, 4, 5, 2, boost::none};
|
||||
PathData kathy{0, 1, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData cathy{0, 3, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none};
|
||||
PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PhantomNode node_1;
|
||||
PhantomNode node_2;
|
||||
PhantomNode node_3;
|
||||
node_1.forward_segment_id = {1, true};
|
||||
node_2.forward_segment_id = {6, true};
|
||||
node_3.forward_segment_id = {12, true};
|
||||
node_1.forward_weight = node_2.forward_weight = node_3.forward_weight = {1};
|
||||
node_1.forward_duration = node_2.forward_duration = node_3.forward_duration = {1};
|
||||
node_1.forward_distance = node_2.forward_distance = node_3.forward_distance = {1};
|
||||
|
||||
InternalRouteResult two_leg_result;
|
||||
two_leg_result.unpacked_path_segments = {{pathy, kathy}, {kathy, cathy}};
|
||||
two_leg_result.leg_endpoints = {PhantomEndpoints{node_1, node_2},
|
||||
PhantomEndpoints{node_2, node_3}};
|
||||
two_leg_result.source_traversed_in_reverse = {true, false};
|
||||
two_leg_result.target_traversed_in_reverse = {true, false};
|
||||
two_leg_result.shortest_path_weight = 80;
|
||||
two_leg_result.shortest_path_weight = {80};
|
||||
|
||||
auto collapsed = CollapseInternalRouteResult(two_leg_result, {true, false, true, true});
|
||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments.size(), 1);
|
||||
@@ -70,11 +74,11 @@ BOOST_AUTO_TEST_CASE(two_legs_to_one_leg)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
||||
{
|
||||
PathData pathy{0, 2, 2, 3, 4, 5, 2, boost::none};
|
||||
PathData kathy{0, 1, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData qathy{0, 5, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData cathy{0, 3, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData mathy{0, 4, 8, 9, 13, 4, 2, boost::none};
|
||||
PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none};
|
||||
PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PathData qathy{0, 5, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PathData mathy{0, 4, {8}, {9}, {13}, {4}, 2, boost::none};
|
||||
PhantomNode node_1;
|
||||
PhantomNode node_2;
|
||||
PhantomNode node_3;
|
||||
@@ -83,6 +87,19 @@ BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
||||
node_2.forward_segment_id = {6, true};
|
||||
node_3.forward_segment_id = {12, true};
|
||||
node_4.forward_segment_id = {18, true};
|
||||
node_1.forward_weight = node_2.forward_weight = node_3.forward_weight =
|
||||
node_4.forward_weight = {1};
|
||||
node_1.forward_duration = node_2.forward_duration = node_3.forward_duration =
|
||||
node_4.forward_duration = {1};
|
||||
node_1.forward_distance = node_2.forward_distance = node_3.forward_distance =
|
||||
node_4.forward_distance = {1};
|
||||
node_1.reverse_weight = node_2.reverse_weight = node_3.reverse_weight =
|
||||
node_4.reverse_weight = {1};
|
||||
node_1.reverse_duration = node_2.reverse_duration = node_3.reverse_duration =
|
||||
node_4.reverse_duration = {1};
|
||||
node_1.reverse_distance = node_2.reverse_distance = node_3.reverse_distance =
|
||||
node_4.reverse_distance = {1};
|
||||
|
||||
InternalRouteResult three_leg_result;
|
||||
three_leg_result.unpacked_path_segments = {std::vector<PathData>{pathy, kathy},
|
||||
std::vector<PathData>{kathy, qathy, cathy},
|
||||
@@ -92,7 +109,7 @@ BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
||||
PhantomEndpoints{node_3, node_4}};
|
||||
three_leg_result.source_traversed_in_reverse = {true, false, true},
|
||||
three_leg_result.target_traversed_in_reverse = {true, false, true},
|
||||
three_leg_result.shortest_path_weight = 140;
|
||||
three_leg_result.shortest_path_weight = {140};
|
||||
|
||||
auto collapsed = CollapseInternalRouteResult(three_leg_result, {true, true, false, true});
|
||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments.size(), 2);
|
||||
@@ -114,9 +131,9 @@ BOOST_AUTO_TEST_CASE(three_legs_to_two_legs)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(two_legs_to_two_legs)
|
||||
{
|
||||
PathData pathy{0, 2, 2, 3, 4, 5, 2, boost::none};
|
||||
PathData kathy{0, 1, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData cathy{0, 3, 1, 2, 3, 4, 1, boost::none};
|
||||
PathData pathy{0, 2, {2}, {3}, {4}, {5}, 2, boost::none};
|
||||
PathData kathy{0, 1, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PathData cathy{0, 3, {1}, {2}, {3}, {4}, 1, boost::none};
|
||||
PhantomNode node_1;
|
||||
PhantomNode node_2;
|
||||
PhantomNode node_3;
|
||||
@@ -129,7 +146,7 @@ BOOST_AUTO_TEST_CASE(two_legs_to_two_legs)
|
||||
PhantomEndpoints{node_2, node_3}};
|
||||
two_leg_result.source_traversed_in_reverse = {true, false};
|
||||
two_leg_result.target_traversed_in_reverse = {true, false};
|
||||
two_leg_result.shortest_path_weight = 80;
|
||||
two_leg_result.shortest_path_weight = {80};
|
||||
|
||||
auto collapsed = CollapseInternalRouteResult(two_leg_result, {true, true, true});
|
||||
BOOST_CHECK_EQUAL(collapsed.unpacked_path_segments.size(), 2);
|
||||
|
||||
@@ -87,14 +87,11 @@ struct ExternalCellStorage
|
||||
return boost::make_iterator_range((EdgeWeight *)0, (EdgeWeight *)0);
|
||||
}
|
||||
|
||||
auto GetSourceNodes() const
|
||||
{
|
||||
return boost::make_iterator_range((EdgeWeight *)0, (EdgeWeight *)0);
|
||||
}
|
||||
auto GetSourceNodes() const { return boost::make_iterator_range((NodeID *)0, (NodeID *)0); }
|
||||
|
||||
auto GetDestinationNodes() const
|
||||
{
|
||||
return boost::make_iterator_range((EdgeWeight *)0, (EdgeWeight *)0);
|
||||
return boost::make_iterator_range((NodeID *)0, (NodeID *)0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -265,7 +262,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
return {};
|
||||
}
|
||||
|
||||
EdgeWeight GetNodeWeight(const NodeID /*node*/) const { return 0; }
|
||||
EdgeWeight GetNodeWeight(const NodeID /*node*/) const { return {0}; }
|
||||
|
||||
bool IsForwardEdge(const NodeID /*edge*/) const { return true; }
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ BOOST_AUTO_TEST_CASE(long_road_test)
|
||||
CompressedEdgeContainer container;
|
||||
|
||||
// compress 0---1---2 to 0---2
|
||||
container.CompressEdge(0, 1, 1, 2, 1, 1, 11, 11);
|
||||
container.CompressEdge(0, 1, 1, 2, {1}, {1}, {11}, {11});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(!container.HasEntryForID(2));
|
||||
@@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(long_road_test)
|
||||
BOOST_CHECK_EQUAL(container.GetLastEdgeSourceID(0), 1);
|
||||
|
||||
// compress 2---3---4 to 2---4
|
||||
container.CompressEdge(2, 3, 3, 4, 1, 1, 11, 11);
|
||||
container.CompressEdge(2, 3, 3, 4, {1}, {1}, {11}, {11});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(container.HasEntryForID(2));
|
||||
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(long_road_test)
|
||||
BOOST_CHECK_EQUAL(container.GetLastEdgeSourceID(2), 3);
|
||||
|
||||
// compress 0---2---4 to 0---4
|
||||
container.CompressEdge(0, 2, 2, 4, 2, 2, 22, 22);
|
||||
container.CompressEdge(0, 2, 2, 4, {2}, {2}, {22}, {22});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(!container.HasEntryForID(2));
|
||||
@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(t_crossing)
|
||||
CompressedEdgeContainer container;
|
||||
|
||||
// compress 0---1---2 to 0---2
|
||||
container.CompressEdge(0, 1, 1, 2, 1, 1, 11, 11);
|
||||
container.CompressEdge(0, 1, 1, 2, {1}, {1}, {11}, {11});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(!container.HasEntryForID(2));
|
||||
@@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(t_crossing)
|
||||
BOOST_CHECK_EQUAL(container.GetLastEdgeSourceID(0), 1);
|
||||
|
||||
// compress 2---5---6 to 2---6
|
||||
container.CompressEdge(4, 5, 5, 6, 1, 1, 11, 11);
|
||||
container.CompressEdge(4, 5, 5, 6, {1}, {1}, {11}, {11});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(!container.HasEntryForID(2));
|
||||
@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(t_crossing)
|
||||
BOOST_CHECK_EQUAL(container.GetLastEdgeSourceID(4), 5);
|
||||
|
||||
// compress 2---3---4 to 2---4
|
||||
container.CompressEdge(2, 3, 3, 4, 1, 1, 11, 11);
|
||||
container.CompressEdge(2, 3, 3, 4, {1}, {1}, {11}, {11});
|
||||
BOOST_CHECK(container.HasEntryForID(0));
|
||||
BOOST_CHECK(!container.HasEntryForID(1));
|
||||
BOOST_CHECK(container.HasEntryForID(2));
|
||||
|
||||
@@ -27,9 +27,9 @@ inline InputEdge MakeUnitEdge(const NodeID from, const NodeID to)
|
||||
{
|
||||
return {from, // source
|
||||
to, // target
|
||||
1, // weight
|
||||
1, // duration
|
||||
1, // distance
|
||||
EdgeWeight{1}, // weight
|
||||
EdgeDuration{1}, // duration
|
||||
EdgeDistance{1}, // distance
|
||||
GeometryID{0, false}, // geometry_id
|
||||
false, // reversed
|
||||
NodeBasedEdgeClassification(), // default flags
|
||||
|
||||
@@ -43,9 +43,9 @@ BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
|
||||
[](const NodeID from, const NodeID to, bool allowed, AnnotationID annotation) {
|
||||
return InputEdge{from,
|
||||
to,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
EdgeWeight{1},
|
||||
EdgeDuration{1},
|
||||
EdgeDistance{1},
|
||||
GeometryID{0, false},
|
||||
!allowed,
|
||||
NodeBasedEdgeClassification(),
|
||||
@@ -170,9 +170,9 @@ BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
|
||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout) {
|
||||
return InputEdge{from,
|
||||
to,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
EdgeWeight{1},
|
||||
EdgeDuration{1},
|
||||
EdgeDistance{1},
|
||||
GeometryID{0, false},
|
||||
!allowed,
|
||||
NodeBasedEdgeClassification{
|
||||
@@ -275,8 +275,15 @@ BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
|
||||
// 6 8 ↔ 9
|
||||
//
|
||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed) {
|
||||
return InputEdge{
|
||||
from, to, 1, 1, 1, GeometryID{0, false}, !allowed, NodeBasedEdgeClassification{}, 0};
|
||||
return InputEdge{from,
|
||||
to,
|
||||
EdgeWeight{1},
|
||||
EdgeDuration{1},
|
||||
EdgeDistance{1},
|
||||
GeometryID{0, false},
|
||||
!allowed,
|
||||
NodeBasedEdgeClassification{},
|
||||
0};
|
||||
};
|
||||
std::vector<InputEdge> edges = {unit_edge(0, 1, true), // 0
|
||||
unit_edge(1, 0, true),
|
||||
|
||||
@@ -47,11 +47,11 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
}
|
||||
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned /* id */) const override final
|
||||
{
|
||||
return 0;
|
||||
return {0};
|
||||
}
|
||||
TurnPenalty GetDurationPenaltyForEdgeID(const unsigned /* id */) const override final
|
||||
{
|
||||
return 0;
|
||||
return {0};
|
||||
}
|
||||
std::string GetTimestamp() const override { return ""; }
|
||||
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
||||
|
||||
@@ -99,14 +99,14 @@ BOOST_AUTO_TEST_CASE(mutable_cell_storage)
|
||||
auto in_range_1_5_11 = cell_1_5.GetInWeight(11);
|
||||
|
||||
fill_range(out_range_1_0_0, {});
|
||||
fill_range(out_range_1_2_4, {1});
|
||||
fill_range(out_range_1_3_6, {2});
|
||||
fill_range(out_range_1_5_11, {3});
|
||||
fill_range(out_range_1_2_4, {EdgeWeight{1}});
|
||||
fill_range(out_range_1_3_6, {EdgeWeight{2}});
|
||||
fill_range(out_range_1_5_11, {EdgeWeight{3}});
|
||||
|
||||
CHECK_EQUAL_COLLECTIONS(in_range_1_1_3, std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_RANGE(in_range_1_2_5, 1);
|
||||
CHECK_EQUAL_RANGE(in_range_1_3_7, 2);
|
||||
CHECK_EQUAL_RANGE(in_range_1_5_11, 3);
|
||||
CHECK_EQUAL_RANGE(in_range_1_2_5, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(in_range_1_3_7, EdgeWeight{2});
|
||||
CHECK_EQUAL_RANGE(in_range_1_5_11, EdgeWeight{3});
|
||||
|
||||
// Level 2
|
||||
auto cell_2_0 = storage.GetCell(metric, 2, 0);
|
||||
@@ -125,14 +125,14 @@ BOOST_AUTO_TEST_CASE(mutable_cell_storage)
|
||||
auto in_range_2_1_7 = cell_2_1.GetInWeight(7);
|
||||
auto in_range_2_3_11 = cell_2_3.GetInWeight(11);
|
||||
|
||||
fill_range(out_range_2_0_0, {1});
|
||||
fill_range(out_range_2_1_4, {2, 3});
|
||||
fill_range(out_range_2_3_11, {4});
|
||||
fill_range(out_range_2_0_0, {EdgeWeight{1}});
|
||||
fill_range(out_range_2_1_4, {EdgeWeight{2}, EdgeWeight{3}});
|
||||
fill_range(out_range_2_3_11, {EdgeWeight{4}});
|
||||
|
||||
CHECK_EQUAL_RANGE(in_range_2_0_3, 1);
|
||||
CHECK_EQUAL_RANGE(in_range_2_1_4, 2);
|
||||
CHECK_EQUAL_RANGE(in_range_2_1_7, 3);
|
||||
CHECK_EQUAL_RANGE(in_range_2_3_11, 4);
|
||||
CHECK_EQUAL_RANGE(in_range_2_0_3, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(in_range_2_1_4, EdgeWeight{2});
|
||||
CHECK_EQUAL_RANGE(in_range_2_1_7, EdgeWeight{3});
|
||||
CHECK_EQUAL_RANGE(in_range_2_3_11, EdgeWeight{4});
|
||||
|
||||
// Level 3
|
||||
auto cell_3_0 = storage.GetCell(metric, 3, 0);
|
||||
@@ -146,13 +146,13 @@ BOOST_AUTO_TEST_CASE(mutable_cell_storage)
|
||||
auto in_range_3_1_4 = cell_3_1.GetInWeight(4);
|
||||
auto in_range_3_1_7 = cell_3_1.GetInWeight(7);
|
||||
|
||||
fill_range(out_range_3_0_0, {1});
|
||||
fill_range(out_range_3_1_4, {2, 3});
|
||||
fill_range(out_range_3_1_7, {4, 5});
|
||||
fill_range(out_range_3_0_0, {EdgeWeight{1}});
|
||||
fill_range(out_range_3_1_4, {EdgeWeight{2}, EdgeWeight{3}});
|
||||
fill_range(out_range_3_1_7, {EdgeWeight{4}, EdgeWeight{5}});
|
||||
|
||||
CHECK_EQUAL_RANGE(in_range_3_0_3, 1);
|
||||
CHECK_EQUAL_RANGE(in_range_3_1_4, 2, 4);
|
||||
CHECK_EQUAL_RANGE(in_range_3_1_7, 3, 5);
|
||||
CHECK_EQUAL_RANGE(in_range_3_0_3, EdgeWeight{1});
|
||||
CHECK_EQUAL_RANGE(in_range_3_1_4, EdgeWeight{2}, EdgeWeight{4});
|
||||
CHECK_EQUAL_RANGE(in_range_3_1_7, EdgeWeight{3}, EdgeWeight{5});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(immutable_cell_storage)
|
||||
@@ -230,17 +230,17 @@ BOOST_AUTO_TEST_CASE(immutable_cell_storage)
|
||||
auto const_cell_1_5 = const_storage.GetCell(metric, 1, 5);
|
||||
|
||||
CHECK_EQUAL_RANGE(const_cell_1_0.GetSourceNodes(), 0);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_1.GetSourceNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_1.GetSourceNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_1_2.GetSourceNodes(), 4);
|
||||
CHECK_EQUAL_RANGE(const_cell_1_3.GetSourceNodes(), 6);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_4.GetSourceNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_4.GetSourceNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_1_5.GetSourceNodes(), 11);
|
||||
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_0.GetDestinationNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_0.GetDestinationNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_1_1.GetDestinationNodes(), 3);
|
||||
CHECK_EQUAL_RANGE(const_cell_1_2.GetDestinationNodes(), 5);
|
||||
CHECK_EQUAL_RANGE(const_cell_1_3.GetDestinationNodes(), 7);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_4.GetDestinationNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_1_4.GetDestinationNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_1_5.GetDestinationNodes(), 11);
|
||||
|
||||
auto out_const_range_1_0_0 = const_cell_1_0.GetOutWeight(0);
|
||||
@@ -271,12 +271,12 @@ BOOST_AUTO_TEST_CASE(immutable_cell_storage)
|
||||
|
||||
CHECK_EQUAL_RANGE(const_cell_2_0.GetSourceNodes(), 0);
|
||||
CHECK_EQUAL_RANGE(const_cell_2_1.GetSourceNodes(), 4);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_2_2.GetSourceNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_2_2.GetSourceNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_2_3.GetSourceNodes(), 11);
|
||||
|
||||
CHECK_EQUAL_RANGE(const_cell_2_0.GetDestinationNodes(), 3);
|
||||
CHECK_EQUAL_RANGE(const_cell_2_1.GetDestinationNodes(), 4, 7);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_2_2.GetDestinationNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_2_2.GetDestinationNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_RANGE(const_cell_2_3.GetDestinationNodes(), 11);
|
||||
|
||||
auto out_const_range_2_0_0 = const_cell_2_0.GetOutWeight(0);
|
||||
@@ -325,8 +325,8 @@ BOOST_AUTO_TEST_CASE(immutable_cell_storage)
|
||||
|
||||
// Level 4
|
||||
auto const_cell_4_0 = const_storage.GetCell(metric, 4, 0);
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_4_0.GetSourceNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_4_0.GetDestinationNodes(), std::vector<EdgeWeight>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_4_0.GetSourceNodes(), std::vector<NodeID>{});
|
||||
CHECK_EQUAL_COLLECTIONS(const_cell_4_0.GetDestinationNodes(), std::vector<NodeID>{});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -32,9 +32,9 @@ auto makeGraph(const std::vector<MockEdge> &mock_edges)
|
||||
max_id = std::max<std::size_t>(max_id, std::max(m.start, m.target));
|
||||
|
||||
edges.push_back(InputEdge{
|
||||
m.start, m.target, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, 1, true, false}});
|
||||
m.start, m.target, EdgeBasedGraphEdgeData{SPECIAL_NODEID, {1}, {1}, {1}, true, false}});
|
||||
edges.push_back(InputEdge{
|
||||
m.target, m.start, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, 1, false, true}});
|
||||
m.target, m.start, EdgeBasedGraphEdgeData{SPECIAL_NODEID, {1}, {1}, {1}, false, true}});
|
||||
}
|
||||
std::sort(edges.begin(), edges.end());
|
||||
return DynamicEdgeBasedGraph(max_id + 1, edges);
|
||||
|
||||
@@ -76,13 +76,13 @@ BOOST_AUTO_TEST_CASE(packed_vector_iterator_test)
|
||||
|
||||
BOOST_CHECK(std::is_sorted(packed_vec.begin(), packed_vec.end()));
|
||||
|
||||
auto idx = 0;
|
||||
auto vec_idx = 0;
|
||||
for (auto value : packed_vec)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(packed_vec[idx], value);
|
||||
idx++;
|
||||
BOOST_CHECK_EQUAL(packed_vec[vec_idx], value);
|
||||
vec_idx++;
|
||||
}
|
||||
BOOST_CHECK_EQUAL(idx, packed_vec.size());
|
||||
BOOST_CHECK_EQUAL(vec_idx, packed_vec.size());
|
||||
|
||||
auto range = boost::make_iterator_range(packed_vec.cbegin(), packed_vec.cend());
|
||||
BOOST_CHECK_EQUAL(range.size(), packed_vec.size());
|
||||
@@ -215,18 +215,38 @@ BOOST_AUTO_TEST_CASE(packed_weights_container_with_type_erasure)
|
||||
|
||||
PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS> vector(7);
|
||||
|
||||
std::iota(vector.begin(), vector.end(), 0);
|
||||
std::iota(vector.begin(), vector.end(), SegmentWeight{0});
|
||||
|
||||
auto forward = boost::make_iterator_range(vector.begin() + 1, vector.begin() + 6);
|
||||
auto forward_any = WeightsAnyRange(forward.begin(), forward.end());
|
||||
|
||||
CHECK_EQUAL_RANGE(forward, 1, 2, 3, 4, 5);
|
||||
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3, 4, 5);
|
||||
CHECK_EQUAL_RANGE(forward,
|
||||
SegmentWeight{1},
|
||||
SegmentWeight{2},
|
||||
SegmentWeight{3},
|
||||
SegmentWeight{4},
|
||||
SegmentWeight{5});
|
||||
CHECK_EQUAL_RANGE(forward_any,
|
||||
SegmentWeight{1},
|
||||
SegmentWeight{2},
|
||||
SegmentWeight{3},
|
||||
SegmentWeight{4},
|
||||
SegmentWeight{5});
|
||||
|
||||
auto reverse = boost::adaptors::reverse(forward);
|
||||
auto reverse_any = WeightsAnyRange(reverse);
|
||||
CHECK_EQUAL_RANGE(reverse, 5, 4, 3, 2, 1);
|
||||
CHECK_EQUAL_RANGE(reverse_any, 5, 4, 3, 2, 1);
|
||||
CHECK_EQUAL_RANGE(reverse,
|
||||
SegmentWeight{5},
|
||||
SegmentWeight{4},
|
||||
SegmentWeight{3},
|
||||
SegmentWeight{2},
|
||||
SegmentWeight{1});
|
||||
CHECK_EQUAL_RANGE(reverse_any,
|
||||
SegmentWeight{5},
|
||||
SegmentWeight{4},
|
||||
SegmentWeight{3},
|
||||
SegmentWeight{2},
|
||||
SegmentWeight{1});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(packed_weights_view_with_type_erasure)
|
||||
@@ -244,14 +264,14 @@ BOOST_AUTO_TEST_CASE(packed_weights_view_with_type_erasure)
|
||||
auto forward = boost::make_iterator_range(view.begin() + 1, view.begin() + 4);
|
||||
auto forward_any = WeightsAnyRange(forward.begin(), forward.end());
|
||||
|
||||
CHECK_EQUAL_RANGE(forward, 1, 2, 3);
|
||||
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3);
|
||||
CHECK_EQUAL_RANGE(forward, SegmentWeight{1}, SegmentWeight{2}, SegmentWeight{3});
|
||||
CHECK_EQUAL_RANGE(forward_any, SegmentWeight{1}, SegmentWeight{2}, SegmentWeight{3});
|
||||
|
||||
auto reverse = boost::adaptors::reverse(forward);
|
||||
auto reverse_any = WeightsAnyRange(reverse);
|
||||
|
||||
CHECK_EQUAL_RANGE(reverse, 3, 2, 1);
|
||||
CHECK_EQUAL_RANGE(reverse_any, 3, 2, 1);
|
||||
CHECK_EQUAL_RANGE(reverse, SegmentWeight{3}, SegmentWeight{2}, SegmentWeight{1});
|
||||
CHECK_EQUAL_RANGE(reverse_any, SegmentWeight{3}, SegmentWeight{2}, SegmentWeight{1});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user