Rename GraphView -> BisectionGraphView to avoid name conflicts
This commit is contained in:
committed by
Patrick Niklaus
parent
e23dc8977f
commit
53f87c08b5
@@ -0,0 +1,53 @@
|
||||
#include "partition/bisection_graph_view.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace partition
|
||||
{
|
||||
|
||||
BisectionGraphView::BisectionGraphView(const BisectionGraph &bisection_graph_)
|
||||
: BisectionGraphView(bisection_graph_, bisection_graph_.CBegin(), bisection_graph_.CEnd())
|
||||
{
|
||||
}
|
||||
|
||||
BisectionGraphView::BisectionGraphView(const BisectionGraph &bisection_graph_,
|
||||
const BisectionGraph::ConstNodeIterator begin_,
|
||||
const BisectionGraph::ConstNodeIterator end_)
|
||||
: bisection_graph(bisection_graph_), begin(begin_), end(end_)
|
||||
{
|
||||
}
|
||||
|
||||
BisectionGraphView::BisectionGraphView(const BisectionGraphView &other_view,
|
||||
const BisectionGraph::ConstNodeIterator begin_,
|
||||
const BisectionGraph::ConstNodeIterator end_)
|
||||
: BisectionGraphView(other_view.bisection_graph, begin_, end_)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t BisectionGraphView::NumberOfNodes() const { return std::distance(begin, end); }
|
||||
|
||||
NodeID BisectionGraphView::GetID(const NodeT &node) const
|
||||
{
|
||||
const auto node_id = static_cast<NodeID>(&node - &(*begin));
|
||||
BOOST_ASSERT(node_id < NumberOfNodes());
|
||||
return node_id;
|
||||
}
|
||||
|
||||
BisectionGraph::ConstNodeIterator BisectionGraphView::Begin() const { return begin; }
|
||||
|
||||
BisectionGraph::ConstNodeIterator BisectionGraphView::End() const { return end; }
|
||||
|
||||
const BisectionGraphView::NodeT &BisectionGraphView::Node(const NodeID nid) const { return *(begin + nid); }
|
||||
|
||||
const BisectionGraphView::EdgeT &BisectionGraphView::Edge(const EdgeID eid) const
|
||||
{
|
||||
return bisection_graph.Edge(eid);
|
||||
}
|
||||
|
||||
} // namespace partition
|
||||
} // namespace osrm
|
||||
@@ -18,7 +18,7 @@ namespace
|
||||
|
||||
const auto constexpr INVALID_LEVEL = std::numeric_limits<DinicMaxFlow::Level>::max();
|
||||
|
||||
auto makeHasNeighborNotInCheck(const DinicMaxFlow::SourceSinkNodes &set, const GraphView &view)
|
||||
auto makeHasNeighborNotInCheck(const DinicMaxFlow::SourceSinkNodes &set, const BisectionGraphView &view)
|
||||
{
|
||||
return [&](const NodeID nid) {
|
||||
const auto is_not_contained = [&set](const BisectionEdge &edge) {
|
||||
@@ -31,7 +31,7 @@ auto makeHasNeighborNotInCheck(const DinicMaxFlow::SourceSinkNodes &set, const G
|
||||
|
||||
} // end namespace
|
||||
|
||||
DinicMaxFlow::MinCut DinicMaxFlow::operator()(const GraphView &view,
|
||||
DinicMaxFlow::MinCut DinicMaxFlow::operator()(const BisectionGraphView &view,
|
||||
const SourceSinkNodes &source_nodes,
|
||||
const SourceSinkNodes &sink_nodes) const
|
||||
{
|
||||
@@ -93,7 +93,7 @@ DinicMaxFlow::MinCut DinicMaxFlow::operator()(const GraphView &view,
|
||||
} while (true);
|
||||
}
|
||||
|
||||
DinicMaxFlow::MinCut DinicMaxFlow::MakeCut(const GraphView &view,
|
||||
DinicMaxFlow::MinCut DinicMaxFlow::MakeCut(const BisectionGraphView &view,
|
||||
const LevelGraph &levels,
|
||||
const std::size_t flow_value) const
|
||||
{
|
||||
@@ -112,7 +112,7 @@ DinicMaxFlow::MinCut DinicMaxFlow::MakeCut(const GraphView &view,
|
||||
}
|
||||
|
||||
DinicMaxFlow::LevelGraph
|
||||
DinicMaxFlow::ComputeLevelGraph(const GraphView &view,
|
||||
DinicMaxFlow::ComputeLevelGraph(const BisectionGraphView &view,
|
||||
const std::vector<NodeID> &border_source_nodes,
|
||||
const SourceSinkNodes &source_nodes,
|
||||
const SourceSinkNodes &sink_nodes,
|
||||
@@ -172,7 +172,7 @@ DinicMaxFlow::ComputeLevelGraph(const GraphView &view,
|
||||
|
||||
std::size_t DinicMaxFlow::BlockingFlow(FlowEdges &flow,
|
||||
LevelGraph &levels,
|
||||
const GraphView &view,
|
||||
const BisectionGraphView &view,
|
||||
const SourceSinkNodes &source_nodes,
|
||||
const std::vector<NodeID> &border_sink_nodes) const
|
||||
{
|
||||
@@ -228,7 +228,7 @@ std::size_t DinicMaxFlow::BlockingFlow(FlowEdges &flow,
|
||||
// INVALID_LEVEL and by following the level graph, this looks at every edge at most `c` times (O(E))
|
||||
std::vector<NodeID> DinicMaxFlow::GetAugmentingPath(LevelGraph &levels,
|
||||
const NodeID node_id,
|
||||
const GraphView &view,
|
||||
const BisectionGraphView &view,
|
||||
const FlowEdges &flow,
|
||||
const SourceSinkNodes &source_nodes) const
|
||||
{
|
||||
@@ -290,7 +290,7 @@ std::vector<NodeID> DinicMaxFlow::GetAugmentingPath(LevelGraph &levels,
|
||||
return path;
|
||||
}
|
||||
|
||||
bool DinicMaxFlow::Validate(const GraphView &view,
|
||||
bool DinicMaxFlow::Validate(const BisectionGraphView &view,
|
||||
const SourceSinkNodes &source_nodes,
|
||||
const SourceSinkNodes &sink_nodes) const
|
||||
{
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "partition/graph_view.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace partition
|
||||
{
|
||||
|
||||
GraphView::GraphView(const BisectionGraph &bisection_graph_)
|
||||
: GraphView(bisection_graph_, bisection_graph_.CBegin(), bisection_graph_.CEnd())
|
||||
{
|
||||
}
|
||||
|
||||
GraphView::GraphView(const BisectionGraph &bisection_graph_,
|
||||
const BisectionGraph::ConstNodeIterator begin_,
|
||||
const BisectionGraph::ConstNodeIterator end_)
|
||||
: bisection_graph(bisection_graph_), begin(begin_), end(end_)
|
||||
{
|
||||
}
|
||||
|
||||
GraphView::GraphView(const GraphView &other_view,
|
||||
const BisectionGraph::ConstNodeIterator begin_,
|
||||
const BisectionGraph::ConstNodeIterator end_)
|
||||
: GraphView(other_view.bisection_graph, begin_, end_)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t GraphView::NumberOfNodes() const { return std::distance(begin, end); }
|
||||
|
||||
NodeID GraphView::GetID(const NodeT &node) const
|
||||
{
|
||||
const auto node_id = static_cast<NodeID>(&node - &(*begin));
|
||||
BOOST_ASSERT(node_id < NumberOfNodes());
|
||||
return node_id;
|
||||
}
|
||||
|
||||
BisectionGraph::ConstNodeIterator GraphView::Begin() const { return begin; }
|
||||
|
||||
BisectionGraph::ConstNodeIterator GraphView::End() const { return end; }
|
||||
|
||||
const GraphView::NodeT &GraphView::Node(const NodeID nid) const { return *(begin + nid); }
|
||||
|
||||
const GraphView::EdgeT &GraphView::Edge(const EdgeID eid) const
|
||||
{
|
||||
return bisection_graph.Edge(eid);
|
||||
}
|
||||
|
||||
} // namespace partition
|
||||
} // namespace osrm
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "partition/inertial_flow.hpp"
|
||||
#include "partition/bisection_graph.hpp"
|
||||
#include "partition/bisection_graph_view.hpp"
|
||||
#include "partition/reorder_first_last.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -32,7 +33,7 @@ struct SpatialOrder
|
||||
|
||||
// Creates a spatial order of n * sources "first" and n * sink "last" node ids.
|
||||
// The slope determines the spatial order for sorting node coordinates.
|
||||
SpatialOrder makeSpatialOrder(const GraphView &view, const double ratio, const double slope)
|
||||
SpatialOrder makeSpatialOrder(const BisectionGraphView &view, const double ratio, const double slope)
|
||||
{
|
||||
struct NodeWithCoordinate
|
||||
{
|
||||
@@ -89,7 +90,7 @@ SpatialOrder makeSpatialOrder(const GraphView &view, const double ratio, const d
|
||||
|
||||
// Makes n cuts with different spatial orders and returns the best.
|
||||
DinicMaxFlow::MinCut
|
||||
bestMinCut(const GraphView &view, const std::size_t n, const double ratio, const double balance)
|
||||
bestMinCut(const BisectionGraphView &view, const std::size_t n, const double ratio, const double balance)
|
||||
{
|
||||
DinicMaxFlow::MinCut best;
|
||||
best.num_edges = -1;
|
||||
@@ -147,7 +148,7 @@ bestMinCut(const GraphView &view, const std::size_t n, const double ratio, const
|
||||
}
|
||||
}
|
||||
|
||||
DinicMaxFlow::MinCut computeInertialFlowCut(const GraphView &view,
|
||||
DinicMaxFlow::MinCut computeInertialFlowCut(const BisectionGraphView &view,
|
||||
const std::size_t num_slopes,
|
||||
const double balance,
|
||||
const double source_sink_rate)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "partition/recursive_bisection.hpp"
|
||||
#include "partition/inertial_flow.hpp"
|
||||
|
||||
#include "partition/graph_view.hpp"
|
||||
#include "partition/bisection_graph_view.hpp"
|
||||
#include "partition/recursive_bisection_state.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
@@ -46,7 +46,7 @@ RecursiveBisection::RecursiveBisection(BisectionGraph &bisection_graph_,
|
||||
|
||||
struct TreeNode
|
||||
{
|
||||
GraphView graph;
|
||||
BisectionGraphView graph;
|
||||
std::uint64_t depth;
|
||||
};
|
||||
|
||||
@@ -82,13 +82,13 @@ RecursiveBisection::RecursiveBisection(BisectionGraph &bisection_graph_,
|
||||
return too_small || too_deep;
|
||||
};
|
||||
|
||||
GraphView left_graph{bisection_graph, node.graph.Begin(), center};
|
||||
BisectionGraphView left_graph{bisection_graph, node.graph.Begin(), center};
|
||||
TreeNode left_node{std::move(left_graph), node.depth + 1};
|
||||
|
||||
if (!terminal(left_node))
|
||||
feeder.add(std::move(left_node));
|
||||
|
||||
GraphView right_graph{bisection_graph, center, node.graph.End()};
|
||||
BisectionGraphView right_graph{bisection_graph, center, node.graph.End()};
|
||||
TreeNode right_node{std::move(right_graph), node.depth + 1};
|
||||
|
||||
if (!terminal(right_node))
|
||||
|
||||
@@ -85,7 +85,7 @@ RecursiveBisectionState::ApplyBisection(const NodeIterator const_begin,
|
||||
return const_begin + std::distance(begin, center);
|
||||
}
|
||||
|
||||
std::vector<GraphView>
|
||||
std::vector<BisectionGraphView>
|
||||
RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_size)
|
||||
{
|
||||
// since our graphs are unidirectional, we don't realy need the scc. But tarjan is so nice and
|
||||
@@ -124,7 +124,7 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
edge.target = mapping[edge.target];
|
||||
});
|
||||
|
||||
std::vector<GraphView> views;
|
||||
std::vector<BisectionGraphView> views;
|
||||
auto last = bisection_graph.CBegin();
|
||||
auto last_id = transform_id(bisection_graph.Begin()->original_id);
|
||||
std::set<std::size_t> ordered_component_ids;
|
||||
@@ -134,12 +134,12 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
ordered_component_ids.insert(itr_id);
|
||||
if (last_id != itr_id)
|
||||
{
|
||||
views.push_back(GraphView(bisection_graph, last, itr));
|
||||
views.push_back(BisectionGraphView(bisection_graph, last, itr));
|
||||
last_id = itr_id;
|
||||
last = itr;
|
||||
}
|
||||
}
|
||||
views.push_back(GraphView(bisection_graph, last, bisection_graph.CEnd()));
|
||||
views.push_back(BisectionGraphView(bisection_graph, last, bisection_graph.CEnd()));
|
||||
|
||||
bool has_small_component = [&]() {
|
||||
for (std::size_t i = 0; i < scc_algo.GetNumberOfComponents(); ++i)
|
||||
@@ -149,7 +149,7 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
}();
|
||||
|
||||
if (!has_small_component)
|
||||
views.push_back(GraphView(bisection_graph, bisection_graph.CEnd(), bisection_graph.CEnd()));
|
||||
views.push_back(BisectionGraphView(bisection_graph, bisection_graph.CEnd(), bisection_graph.CEnd()));
|
||||
|
||||
// apply scc as bisections, we need scc_level bits for this with scc_levels =
|
||||
// ceil(log_2(components))
|
||||
|
||||
Reference in New Issue
Block a user