2018-02-01 10:47:43 -05:00
|
|
|
#ifndef OSRM_PARTITIONER_BISECTION_GRAPHVIEW_HPP_
|
|
|
|
#define OSRM_PARTITIONER_BISECTION_GRAPHVIEW_HPP_
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
#include "partitioner/bisection_graph.hpp"
|
2017-01-23 05:50:03 -05:00
|
|
|
|
|
|
|
#include <boost/iterator/filter_iterator.hpp>
|
|
|
|
#include <boost/iterator/iterator_facade.hpp>
|
2017-02-01 09:50:06 -05:00
|
|
|
#include <boost/range/iterator_range.hpp>
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2017-01-25 04:59:27 -05:00
|
|
|
#include <cstddef>
|
2017-01-26 04:34:01 -05:00
|
|
|
#include <cstdint>
|
2017-01-25 04:59:27 -05:00
|
|
|
|
2017-01-23 05:50:03 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
2018-02-01 10:47:43 -05:00
|
|
|
namespace partitioner
|
2017-01-23 05:50:03 -05:00
|
|
|
{
|
|
|
|
|
2017-01-25 04:59:27 -05:00
|
|
|
// Non-owning immutable sub-graph view into a base graph.
|
|
|
|
// The part of the graph to select is determined by the recursive bisection state.
|
2017-08-22 15:52:42 -04:00
|
|
|
class BisectionGraphView
|
2017-01-23 05:50:03 -05:00
|
|
|
{
|
|
|
|
public:
|
2017-02-01 09:50:06 -05:00
|
|
|
using ConstNodeIterator = BisectionGraph::ConstNodeIterator;
|
|
|
|
using NodeIterator = BisectionGraph::NodeIterator;
|
|
|
|
using NodeT = BisectionGraph::NodeT;
|
|
|
|
using EdgeT = BisectionGraph::EdgeT;
|
2017-01-26 04:34:01 -05:00
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
// Construction either for a subrange, or for a full range
|
2017-08-22 15:52:42 -04:00
|
|
|
BisectionGraphView(const BisectionGraph &graph);
|
|
|
|
BisectionGraphView(const BisectionGraph &graph,
|
2017-08-20 19:24:05 -04:00
|
|
|
const ConstNodeIterator begin,
|
|
|
|
const ConstNodeIterator end);
|
2017-02-01 09:50:06 -05:00
|
|
|
|
|
|
|
// construction from a different view, no need to keep the graph around
|
2017-08-20 19:24:05 -04:00
|
|
|
BisectionGraphView(const BisectionGraphView &view,
|
|
|
|
const ConstNodeIterator begin,
|
|
|
|
const ConstNodeIterator end);
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2017-01-25 05:29:37 -05:00
|
|
|
// Number of nodes _in this sub-graph.
|
2017-01-23 05:50:03 -05:00
|
|
|
std::size_t NumberOfNodes() const;
|
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
// Iteration over all nodes (direct access into the node)
|
|
|
|
ConstNodeIterator Begin() const;
|
|
|
|
ConstNodeIterator End() const;
|
2017-02-02 09:53:42 -05:00
|
|
|
auto Nodes() const { return boost::make_iterator_range(begin, end); }
|
2017-01-25 05:29:37 -05:00
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
// Re-Construct the ID of a node from a reference
|
|
|
|
NodeID GetID(const NodeT &node) const;
|
2017-01-25 04:42:13 -05:00
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
// Access into single nodes/Edges
|
|
|
|
const NodeT &Node(const NodeID nid) const;
|
|
|
|
const EdgeT &Edge(const EdgeID eid) const;
|
2017-01-26 04:34:01 -05:00
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
// Access into all Edges
|
2017-02-02 09:53:42 -05:00
|
|
|
auto Edges(const NodeT &node) const { return bisection_graph.Edges(node); }
|
2017-02-01 09:50:06 -05:00
|
|
|
auto Edges(const NodeID nid) const { return bisection_graph.Edges(*(begin + nid)); }
|
|
|
|
auto BeginEdges(const NodeID nid) const { return bisection_graph.BeginEdges(*(begin + nid)); }
|
|
|
|
auto EndEdges(const NodeID nid) const { return bisection_graph.EndEdges(*(begin + nid)); }
|
2017-01-26 04:34:01 -05:00
|
|
|
|
2017-01-23 05:50:03 -05:00
|
|
|
private:
|
|
|
|
const BisectionGraph &bisection_graph;
|
|
|
|
|
2017-01-26 04:34:01 -05:00
|
|
|
const BisectionGraph::ConstNodeIterator begin;
|
|
|
|
const BisectionGraph::ConstNodeIterator end;
|
2017-01-23 05:50:03 -05:00
|
|
|
};
|
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
} // namespace partitioner
|
2017-01-23 05:50:03 -05:00
|
|
|
} // namespace osrm
|
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
#endif // OSRM_PARTITIONER_GRAPHVIEW_HPP_
|