Upgrade clang-format to version 15 (#6859)
This commit is contained in:
@@ -65,8 +65,8 @@ inline BisectionGraph makeBisectionGraph(const std::vector<util::Coordinate> &co
|
||||
result_edges.reserve(edges.size());
|
||||
|
||||
// find the end of edges that belong to node_id
|
||||
const auto advance_edge_itr = [&edges, &result_edges](const std::size_t node_id,
|
||||
auto edge_itr) {
|
||||
const auto advance_edge_itr = [&edges, &result_edges](const std::size_t node_id, auto edge_itr)
|
||||
{
|
||||
while (edge_itr != edges.end() && edge_itr->source == node_id)
|
||||
{
|
||||
result_edges.push_back(edge_itr->Reduce());
|
||||
@@ -76,9 +76,9 @@ inline BisectionGraph makeBisectionGraph(const std::vector<util::Coordinate> &co
|
||||
};
|
||||
|
||||
// create a bisection node, requires the ID of the node as well as the lower bound to its edges
|
||||
const auto make_bisection_node = [&edges, &coordinates](const std::size_t node_id,
|
||||
const auto begin_itr,
|
||||
const auto end_itr) {
|
||||
const auto make_bisection_node =
|
||||
[&edges, &coordinates](const std::size_t node_id, const auto begin_itr, const auto end_itr)
|
||||
{
|
||||
std::size_t range_begin = std::distance(edges.begin(), begin_itr);
|
||||
std::size_t range_end = std::distance(edges.begin(), end_itr);
|
||||
return BisectionGraph::NodeT(range_begin, range_end, coordinates[node_id], node_id);
|
||||
@@ -102,9 +102,12 @@ std::vector<BisectionInputEdge> adaptToBisectionEdge(std::vector<InputEdge> edge
|
||||
std::vector<BisectionInputEdge> result;
|
||||
result.reserve(edges.size());
|
||||
|
||||
std::transform(begin(edges), end(edges), std::back_inserter(result), [](const auto &edge) {
|
||||
return BisectionInputEdge{edge.source, edge.target};
|
||||
});
|
||||
std::transform(begin(edges),
|
||||
end(edges),
|
||||
std::back_inserter(result),
|
||||
[](const auto &edge) {
|
||||
return BisectionInputEdge{edge.source, edge.target};
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,8 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
auto set_num_nodes_fn,
|
||||
auto set_boundary_offset_fn,
|
||||
auto begin,
|
||||
auto end) {
|
||||
auto end)
|
||||
{
|
||||
BOOST_ASSERT(std::distance(begin, end) > 0);
|
||||
|
||||
const auto cell_id = begin->first;
|
||||
@@ -316,7 +317,8 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
util::for_each_range(
|
||||
level_source_boundary.begin(),
|
||||
level_source_boundary.end(),
|
||||
[this, insert_cell_boundary](auto begin, auto end) {
|
||||
[this, insert_cell_boundary](auto begin, auto end)
|
||||
{
|
||||
insert_cell_boundary(
|
||||
source_boundary,
|
||||
[](auto &cell, auto value) { cell.num_source_nodes = value; },
|
||||
@@ -327,7 +329,8 @@ template <storage::Ownership Ownership> class CellStorageImpl
|
||||
util::for_each_range(
|
||||
level_destination_boundary.begin(),
|
||||
level_destination_boundary.end(),
|
||||
[this, insert_cell_boundary](auto begin, auto end) {
|
||||
[this, insert_cell_boundary](auto begin, auto end)
|
||||
{
|
||||
insert_cell_boundary(
|
||||
destination_boundary,
|
||||
[](auto &cell, auto value) { cell.num_destination_nodes = value; },
|
||||
|
||||
@@ -64,10 +64,13 @@ std::vector<OutputEdgeT> prepareEdgesForUsageInGraph(std::vector<extractor::Edge
|
||||
// sort into blocks of edges with same source + target
|
||||
// the we partition by the forward flag to sort all edges with a forward direction first.
|
||||
// the we sort by weight to ensure the first forward edge is the smallest forward edge
|
||||
std::sort(begin(edges), end(edges), [](const auto &lhs, const auto &rhs) {
|
||||
return std::tie(lhs.source, lhs.target, rhs.data.forward, lhs.data.weight) <
|
||||
std::tie(rhs.source, rhs.target, lhs.data.forward, rhs.data.weight);
|
||||
});
|
||||
std::sort(begin(edges),
|
||||
end(edges),
|
||||
[](const auto &lhs, const auto &rhs)
|
||||
{
|
||||
return std::tie(lhs.source, lhs.target, rhs.data.forward, lhs.data.weight) <
|
||||
std::tie(rhs.source, rhs.target, lhs.data.forward, rhs.data.weight);
|
||||
});
|
||||
|
||||
std::vector<OutputEdgeT> output_edges;
|
||||
output_edges.reserve(edges.size());
|
||||
@@ -77,10 +80,11 @@ std::vector<OutputEdgeT> prepareEdgesForUsageInGraph(std::vector<extractor::Edge
|
||||
const NodeID source = begin_interval->source;
|
||||
const NodeID target = begin_interval->target;
|
||||
|
||||
auto end_interval =
|
||||
std::find_if_not(begin_interval, edges.end(), [source, target](const auto &edge) {
|
||||
return std::tie(edge.source, edge.target) == std::tie(source, target);
|
||||
});
|
||||
auto end_interval = std::find_if_not(
|
||||
begin_interval,
|
||||
edges.end(),
|
||||
[source, target](const auto &edge)
|
||||
{ return std::tie(edge.source, edge.target) == std::tie(source, target); });
|
||||
BOOST_ASSERT(begin_interval != end_interval);
|
||||
|
||||
// remove eigenloops
|
||||
@@ -144,7 +148,8 @@ graphToEdges(const DynamicEdgeBasedGraph &edge_based_graph)
|
||||
auto max_turn_id = tbb::parallel_reduce(
|
||||
range,
|
||||
NodeID{0},
|
||||
[&edge_based_graph](const auto range, NodeID initial) {
|
||||
[&edge_based_graph](const auto range, NodeID initial)
|
||||
{
|
||||
NodeID max_turn_id = initial;
|
||||
for (auto node = range.begin(); node < range.end(); ++node)
|
||||
{
|
||||
@@ -159,26 +164,29 @@ graphToEdges(const DynamicEdgeBasedGraph &edge_based_graph)
|
||||
[](const NodeID lhs, const NodeID rhs) { return std::max(lhs, rhs); });
|
||||
|
||||
std::vector<extractor::EdgeBasedEdge> edges(max_turn_id + 1);
|
||||
tbb::parallel_for(range, [&](const auto range) {
|
||||
for (auto node = range.begin(); node < range.end(); ++node)
|
||||
tbb::parallel_for(
|
||||
range,
|
||||
[&](const auto range)
|
||||
{
|
||||
for (auto edge : edge_based_graph.GetAdjacentEdgeRange(node))
|
||||
for (auto node = range.begin(); node < range.end(); ++node)
|
||||
{
|
||||
const auto &data = edge_based_graph.GetEdgeData(edge);
|
||||
// we only need to save the forward edges, since the read method will
|
||||
// convert from forward to bi-directional edges again
|
||||
if (data.forward)
|
||||
for (auto edge : edge_based_graph.GetAdjacentEdgeRange(node))
|
||||
{
|
||||
auto target = edge_based_graph.GetTarget(edge);
|
||||
BOOST_ASSERT(data.turn_id <= max_turn_id);
|
||||
edges[data.turn_id] = extractor::EdgeBasedEdge{node, target, data};
|
||||
// only save the forward edge
|
||||
edges[data.turn_id].data.forward = true;
|
||||
edges[data.turn_id].data.backward = false;
|
||||
const auto &data = edge_based_graph.GetEdgeData(edge);
|
||||
// we only need to save the forward edges, since the read method will
|
||||
// convert from forward to bi-directional edges again
|
||||
if (data.forward)
|
||||
{
|
||||
auto target = edge_based_graph.GetTarget(edge);
|
||||
BOOST_ASSERT(data.turn_id <= max_turn_id);
|
||||
edges[data.turn_id] = extractor::EdgeBasedEdge{node, target, data};
|
||||
// only save the forward edge
|
||||
edges[data.turn_id].data.forward = true;
|
||||
edges[data.turn_id].data.backward = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return edges;
|
||||
}
|
||||
|
||||
@@ -159,10 +159,11 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
||||
auto GetHighestBorderLevel(const MultiLevelPartition &mlp, const ContainerT &edges) const
|
||||
{
|
||||
std::vector<LevelID> highest_border_level(edges.size());
|
||||
std::transform(
|
||||
edges.begin(), edges.end(), highest_border_level.begin(), [&mlp](const auto &edge) {
|
||||
return mlp.GetHighestDifferentLevel(edge.source, edge.target);
|
||||
});
|
||||
std::transform(edges.begin(),
|
||||
edges.end(),
|
||||
highest_border_level.begin(),
|
||||
[&mlp](const auto &edge)
|
||||
{ return mlp.GetHighestDifferentLevel(edge.source, edge.target); });
|
||||
return highest_border_level;
|
||||
}
|
||||
|
||||
@@ -175,7 +176,8 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
||||
tbb::parallel_sort(
|
||||
permutation.begin(),
|
||||
permutation.end(),
|
||||
[&edges, &highest_border_level](const auto &lhs, const auto &rhs) {
|
||||
[&edges, &highest_border_level](const auto &lhs, const auto &rhs)
|
||||
{
|
||||
// sort by source node and then by level in ascending order
|
||||
return std::tie(edges[lhs].source, highest_border_level[lhs], edges[lhs].target) <
|
||||
std::tie(edges[rhs].source, highest_border_level[rhs], edges[rhs].target);
|
||||
@@ -201,11 +203,12 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
||||
auto level_begin = iter;
|
||||
for (auto level : util::irange<LevelID>(0, mlp.GetNumberOfLevels()))
|
||||
{
|
||||
iter = std::find_if(
|
||||
iter, edge_and_level_end, [node, level](const auto &edge_and_level) {
|
||||
return boost::get<0>(edge_and_level).source != node ||
|
||||
boost::get<1>(edge_and_level) != level;
|
||||
});
|
||||
iter = std::find_if(iter,
|
||||
edge_and_level_end,
|
||||
[node, level](const auto &edge_and_level) {
|
||||
return boost::get<0>(edge_and_level).source != node ||
|
||||
boost::get<1>(edge_and_level) != level;
|
||||
});
|
||||
EdgeOffset offset = std::distance(level_begin, iter);
|
||||
node_to_edge_offset.push_back(offset);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,8 @@ template <storage::Ownership Ownership> class MultiLevelPartitionImpl final
|
||||
auto lidx = 0UL;
|
||||
util::for_each_pair(level_offsets.begin(),
|
||||
level_offsets.begin() + num_level,
|
||||
[&](const auto offset, const auto next_offset) {
|
||||
[&](const auto offset, const auto next_offset)
|
||||
{
|
||||
// create mask that has `bits` ones at its LSBs.
|
||||
// 000011
|
||||
BOOST_ASSERT(offset <= NUM_PARTITION_BITS);
|
||||
@@ -274,9 +275,8 @@ template <storage::Ownership Ownership> class MultiLevelPartitionImpl final
|
||||
{
|
||||
std::stable_sort(permutation.begin(),
|
||||
permutation.end(),
|
||||
[&partition](const auto lhs, const auto rhs) {
|
||||
return partition[lhs] < partition[rhs];
|
||||
});
|
||||
[&partition](const auto lhs, const auto rhs)
|
||||
{ return partition[lhs] < partition[rhs]; });
|
||||
}
|
||||
|
||||
// top down assign new cell ids
|
||||
|
||||
@@ -21,7 +21,7 @@ template <typename Base> class NodeEntryWrapper : public Base
|
||||
{
|
||||
public:
|
||||
template <typename... Args>
|
||||
NodeEntryWrapper(std::size_t edges_begin_, std::size_t edges_end_, Args &&... args)
|
||||
NodeEntryWrapper(std::size_t edges_begin_, std::size_t edges_end_, Args &&...args)
|
||||
: Base(std::forward<Args>(args)...), edges_begin(edges_begin_), edges_end(edges_end_)
|
||||
{
|
||||
}
|
||||
@@ -41,7 +41,7 @@ template <typename Base> class GraphConstructionWrapper : public Base
|
||||
{
|
||||
public:
|
||||
template <typename... Args>
|
||||
GraphConstructionWrapper(const NodeID source_, Args &&... args)
|
||||
GraphConstructionWrapper(const NodeID source_, Args &&...args)
|
||||
: Base(std::forward<Args>(args)...), source(source_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,11 +59,13 @@ std::size_t removeUnconnectedBoundaryNodes(const GraphT &edge_based_graph,
|
||||
|
||||
if (level_index < static_cast<int>(partitions.size() - 1))
|
||||
{
|
||||
auto new_end = std::remove_if(
|
||||
witnesses.begin(), witnesses.end(), [&](const auto &witness) {
|
||||
return partitions[level_index + 1][node] !=
|
||||
partitions[level_index + 1][witness.id];
|
||||
});
|
||||
auto new_end =
|
||||
std::remove_if(witnesses.begin(),
|
||||
witnesses.end(),
|
||||
[&](const auto &witness) {
|
||||
return partitions[level_index + 1][node] !=
|
||||
partitions[level_index + 1][witness.id];
|
||||
});
|
||||
witnesses.resize(new_end - witnesses.begin());
|
||||
}
|
||||
if (witnesses.size() == 0)
|
||||
@@ -87,10 +89,12 @@ std::size_t removeUnconnectedBoundaryNodes(const GraphT &edge_based_graph,
|
||||
}
|
||||
}
|
||||
|
||||
auto best_witness = std::min_element(
|
||||
witnesses.begin(), witnesses.end(), [](const auto &lhs, const auto &rhs) {
|
||||
return lhs.induced_border_edges < rhs.induced_border_edges;
|
||||
});
|
||||
auto best_witness =
|
||||
std::min_element(witnesses.begin(),
|
||||
witnesses.end(),
|
||||
[](const auto &lhs, const auto &rhs) {
|
||||
return lhs.induced_border_edges < rhs.induced_border_edges;
|
||||
});
|
||||
BOOST_ASSERT(best_witness != witnesses.end());
|
||||
|
||||
// assign `node` to same subcells as `best_witness`
|
||||
|
||||
@@ -30,10 +30,10 @@ void reorderFirstLast(RandomIt first, RandomIt last, std::size_t n, Comparator c
|
||||
// requirements.
|
||||
std::reverse_iterator<RandomIt> rfirst{last}, rlast{first + n};
|
||||
|
||||
const auto flipped = [](auto fn) {
|
||||
return [fn](auto &&lhs, auto &&rhs) {
|
||||
return fn(std::forward<decltype(lhs)>(rhs), std::forward<decltype(rhs)>(lhs));
|
||||
};
|
||||
const auto flipped = [](auto fn)
|
||||
{
|
||||
return [fn](auto &&lhs, auto &&rhs)
|
||||
{ return fn(std::forward<decltype(lhs)>(rhs), std::forward<decltype(rhs)>(lhs)); };
|
||||
};
|
||||
|
||||
std::nth_element(rfirst, rfirst + (n - 1), rlast, flipped(comp));
|
||||
|
||||
Reference in New Issue
Block a user