Add duration to edges and use it in table plugin

This commit is contained in:
Michael Krasnyk
2017-01-19 22:52:09 +01:00
committed by Patrick Niklaus
parent c059d15cb9
commit 25baf51a2c
24 changed files with 312 additions and 126 deletions
+6 -3
View File
@@ -12,21 +12,24 @@ namespace contractor
struct ContractorEdgeData
{
ContractorEdgeData()
: weight(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
: weight(0), duration(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
is_original_via_node_ID(false)
{
}
ContractorEdgeData(EdgeWeight weight,
EdgeWeight duration,
unsigned original_edges,
unsigned id,
bool shortcut,
bool forward,
bool backward)
: weight(weight), id(id), originalEdges(std::min((unsigned)1 << 28, original_edges)),
shortcut(shortcut), forward(forward), backward(backward), is_original_via_node_ID(false)
: weight(weight), duration(duration), id(id),
originalEdges(std::min((unsigned)1 << 28, original_edges)), shortcut(shortcut),
forward(forward), backward(backward), is_original_via_node_ID(false)
{
}
EdgeWeight weight;
EdgeWeight duration;
unsigned id;
unsigned originalEdges : 28;
bool shortcut : 1;
+6
View File
@@ -134,6 +134,7 @@ class GraphContractor
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.source, "Source id invalid");
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
new_edge.data.weight = data.weight;
new_edge.data.duration = data.duration;
new_edge.data.shortcut = data.shortcut;
if (!data.is_original_via_node_ID && !orig_node_id_from_new_node_id_map.empty())
{
@@ -241,6 +242,7 @@ class GraphContractor
inserted_edges.emplace_back(source,
target,
path_weight,
in_data.duration + out_data.duration,
out_data.originalEdges +
in_data.originalEdges,
node,
@@ -251,6 +253,7 @@ class GraphContractor
inserted_edges.emplace_back(target,
source,
path_weight,
in_data.duration + out_data.duration,
out_data.originalEdges +
in_data.originalEdges,
node,
@@ -294,6 +297,7 @@ class GraphContractor
const NodeID target = contractor_graph->GetTarget(out_edge);
if (target == node)
continue;
const EdgeWeight path_weight = in_data.weight + out_data.weight;
const EdgeWeight weight = dijkstra.GetKey(target);
if (path_weight < weight)
@@ -310,6 +314,7 @@ class GraphContractor
inserted_edges.emplace_back(source,
target,
path_weight,
in_data.duration + out_data.duration,
out_data.originalEdges + in_data.originalEdges,
node,
SHORTCUT_ARC,
@@ -319,6 +324,7 @@ class GraphContractor
inserted_edges.emplace_back(target,
source,
path_weight,
in_data.duration + out_data.duration,
out_data.originalEdges + in_data.originalEdges,
node,
SHORTCUT_ARC,
@@ -33,6 +33,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
edges.emplace_back(input_edge.source,
input_edge.target,
std::max(input_edge.weight, 1),
input_edge.duration,
1,
input_edge.edge_id,
false,
@@ -42,6 +43,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
edges.emplace_back(input_edge.target,
input_edge.source,
std::max(input_edge.weight, 1),
input_edge.duration,
1,
input_edge.edge_id,
false,
+12 -7
View File
@@ -16,11 +16,15 @@ struct QueryEdge
NodeID target;
struct EdgeData
{
EdgeData() : id(0), shortcut(false), weight(0), forward(false), backward(false) {}
explicit EdgeData()
: id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false)
{
}
template <class OtherT> EdgeData(const OtherT &other)
{
weight = other.weight;
duration = other.duration;
shortcut = other.shortcut;
id = other.id;
forward = other.forward;
@@ -31,9 +35,10 @@ struct QueryEdge
// node. Otherwise we see the edge based node to access node data.
NodeID id : 31;
bool shortcut : 1;
EdgeWeight weight : 30;
bool forward : 1;
bool backward : 1;
EdgeWeight weight;
EdgeWeight duration : 30;
std::uint32_t forward : 1;
std::uint32_t backward : 1;
} data;
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
@@ -51,9 +56,9 @@ struct QueryEdge
bool operator==(const QueryEdge &right) const
{
return (source == right.source && target == right.target &&
data.weight == right.data.weight && data.shortcut == right.data.shortcut &&
data.forward == right.data.forward && data.backward == right.data.backward &&
data.id == right.data.id);
data.weight == right.data.weight && data.duration == right.data.duration &&
data.shortcut == right.data.shortcut && data.forward == right.data.forward &&
data.backward == right.data.backward && data.id == right.data.id);
}
};
}