2018-02-01 10:47:43 -05:00
|
|
|
#ifndef OSRM_PARTITIONER_RECURSIVE_BISECTION_STATE_HPP_
|
|
|
|
#define OSRM_PARTITIONER_RECURSIVE_BISECTION_STATE_HPP_
|
2017-01-23 05:50:03 -05:00
|
|
|
|
|
|
|
#include <cstddef>
|
2017-01-26 04:34:01 -05:00
|
|
|
#include <cstdint>
|
2017-01-23 05:50:03 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
#include "partitioner/bisection_graph.hpp"
|
|
|
|
#include "partitioner/bisection_graph_view.hpp"
|
2017-01-23 05:50:03 -05:00
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::partitioner
|
2017-01-23 05:50:03 -05:00
|
|
|
{
|
|
|
|
|
2017-02-02 09:53:42 -05:00
|
|
|
// Keeps track of the bisection ids, modifies the graph accordingly, splitting it into a left/right
|
|
|
|
// section with consecutively labelled nodes. Requires a GraphView to look at.
|
2017-01-23 05:50:03 -05:00
|
|
|
class RecursiveBisectionState
|
|
|
|
{
|
|
|
|
public:
|
2017-01-25 04:42:13 -05:00
|
|
|
// The ID in the partition array
|
2017-01-26 04:34:01 -05:00
|
|
|
using NodeIterator = BisectionGraph::ConstNodeIterator;
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2017-01-26 04:34:01 -05:00
|
|
|
RecursiveBisectionState(BisectionGraph &bisection_graph);
|
2017-01-23 05:50:03 -05:00
|
|
|
~RecursiveBisectionState();
|
|
|
|
|
2017-01-26 04:34:01 -05:00
|
|
|
BisectionID GetBisectionID(const NodeID node) const;
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2017-01-25 04:42:13 -05:00
|
|
|
// Bisects the node id array's sub-range based on the partition mask.
|
|
|
|
// Returns: partition point of the bisection: iterator to the second group's first element.
|
2017-01-26 04:34:01 -05:00
|
|
|
NodeIterator ApplyBisection(NodeIterator begin,
|
|
|
|
const NodeIterator end,
|
|
|
|
const std::size_t depth,
|
|
|
|
const std::vector<bool> &partition);
|
2017-01-23 05:50:03 -05:00
|
|
|
|
2017-02-02 09:53:42 -05:00
|
|
|
// perform an initial pre-partitioning into small components
|
|
|
|
// on larger graphs, SCCs give perfect cuts (think Amerika vs Europe)
|
|
|
|
// This function performs an initial pre-partitioning using these sccs.
|
2017-08-22 15:52:42 -04:00
|
|
|
std::vector<BisectionGraphView> PrePartitionWithSCC(const std::size_t small_component_size);
|
2017-02-02 09:53:42 -05:00
|
|
|
|
2017-02-01 09:50:06 -05:00
|
|
|
const std::vector<BisectionID> &BisectionIDs() const;
|
|
|
|
|
2017-02-07 04:26:29 -05:00
|
|
|
// return the depth encoded in the SCCs
|
|
|
|
std::uint32_t SCCDepth() const;
|
|
|
|
|
2017-01-23 05:50:03 -05:00
|
|
|
private:
|
2017-02-07 04:26:29 -05:00
|
|
|
std::uint32_t scc_levels;
|
2017-01-26 04:34:01 -05:00
|
|
|
BisectionGraph &bisection_graph;
|
2017-01-23 05:50:03 -05:00
|
|
|
std::vector<BisectionID> bisection_ids;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace osrm
|
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
#endif // OSRM_PARTITIONER_RECURSIVE_BISECTION_STATE_HPP_
|