Add edge-based graph loading in MLD facade

This commit is contained in:
Michael Krasnyk
2017-03-06 23:00:11 +01:00
committed by Patrick Niklaus
parent 53b0417e36
commit f42136637d
15 changed files with 406 additions and 178 deletions
+29 -15
View File
@@ -29,11 +29,29 @@ struct EdgeBasedEdge
NodeID source;
NodeID target;
NodeID edge_id;
EdgeWeight weight;
EdgeWeight duration : 30;
std::uint32_t forward : 1;
std::uint32_t backward : 1;
struct EdgeData
{
EdgeData() : edge_id(0), weight(0), duration(0), forward(false), backward(false) {}
EdgeData(const NodeID edge_id,
const EdgeWeight weight,
const EdgeWeight duration,
const bool forward,
const bool backward)
: edge_id(edge_id), weight(weight), duration(duration), forward(forward),
backward(backward)
{
}
NodeID edge_id;
EdgeWeight weight;
EdgeWeight duration : 30;
std::uint32_t forward : 1;
std::uint32_t backward : 1;
auto is_unidirectional() const { return !forward || !backward; }
} data;
};
static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
"Size of extractor::EdgeBasedEdge type is "
@@ -42,10 +60,7 @@ static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
// Impl.
inline EdgeBasedEdge::EdgeBasedEdge()
: source(0), target(0), edge_id(0), weight(0), duration(0), forward(false), backward(false)
{
}
inline EdgeBasedEdge::EdgeBasedEdge() : source(0), target(0) {}
inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
const NodeID target,
@@ -54,19 +69,18 @@ inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
const EdgeWeight duration,
const bool forward,
const bool backward)
: source(source), target(target), edge_id(edge_id), weight(weight), duration(duration),
forward(forward), backward(backward)
: source(source), target(target), data{edge_id, weight, duration, forward, backward}
{
}
inline bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const
{
const auto unidirectional = (!forward || !backward);
const auto other_is_unidirectional = (!other.forward || !other.backward);
const auto unidirectional = data.is_unidirectional();
const auto other_is_unidirectional = other.data.is_unidirectional();
// if all items are the same, we want to keep bidirectional edges. due to the `<` operator,
// preferring 0 (false) over 1 (true), we need to compare the inverse of `bidirectional`
return std::tie(source, target, weight, unidirectional) <
std::tie(other.source, other.target, other.weight, other_is_unidirectional);
return std::tie(source, target, data.weight, unidirectional) <
std::tie(other.source, other.target, other.data.weight, other_is_unidirectional);
}
} // ns extractor
} // ns osrm