Upgrade clang-format to version 15 (#6859)
This commit is contained in:
@@ -45,9 +45,8 @@ RecursiveBisectionState::ApplyBisection(const NodeIterator const_begin,
|
||||
}
|
||||
|
||||
// Keep items with `0` as partition id to the left, move other to the right
|
||||
auto by_flag_bit = [this, flag](const auto &node) {
|
||||
return BisectionID{0} == (bisection_ids[node.original_id] & flag);
|
||||
};
|
||||
auto by_flag_bit = [this, flag](const auto &node)
|
||||
{ return BisectionID{0} == (bisection_ids[node.original_id] & flag); };
|
||||
|
||||
auto begin = bisection_graph.Begin() + std::distance(bisection_graph.CBegin(), const_begin);
|
||||
const auto end = begin + std::distance(const_begin, const_end);
|
||||
@@ -59,26 +58,34 @@ RecursiveBisectionState::ApplyBisection(const NodeIterator const_begin,
|
||||
std::transform(const_begin,
|
||||
const_end,
|
||||
mapping.begin(),
|
||||
[by_flag_bit, &lesser_id, &upper_id](const auto &node) {
|
||||
return by_flag_bit(node) ? lesser_id++ : upper_id++;
|
||||
});
|
||||
[by_flag_bit, &lesser_id, &upper_id](const auto &node)
|
||||
{ return by_flag_bit(node) ? lesser_id++ : upper_id++; });
|
||||
|
||||
// erase all edges that point into different partitions
|
||||
std::for_each(begin, end, [&](auto &node) {
|
||||
const auto node_flag = by_flag_bit(node);
|
||||
bisection_graph.RemoveEdges(node, [&](const BisectionGraph::EdgeT &edge) {
|
||||
const auto target_flag = by_flag_bit(*(const_begin + edge.target));
|
||||
return (node_flag != target_flag);
|
||||
});
|
||||
});
|
||||
std::for_each(begin,
|
||||
end,
|
||||
[&](auto &node)
|
||||
{
|
||||
const auto node_flag = by_flag_bit(node);
|
||||
bisection_graph.RemoveEdges(node,
|
||||
[&](const BisectionGraph::EdgeT &edge)
|
||||
{
|
||||
const auto target_flag =
|
||||
by_flag_bit(*(const_begin + edge.target));
|
||||
return (node_flag != target_flag);
|
||||
});
|
||||
});
|
||||
|
||||
auto center = std::stable_partition(begin, end, by_flag_bit);
|
||||
|
||||
// remap all remaining edges
|
||||
std::for_each(const_begin, const_end, [&](const auto &node) {
|
||||
for (auto &edge : bisection_graph.Edges(node))
|
||||
edge.target = mapping[edge.target];
|
||||
});
|
||||
std::for_each(const_begin,
|
||||
const_end,
|
||||
[&](const auto &node)
|
||||
{
|
||||
for (auto &edge : bisection_graph.Edges(node))
|
||||
edge.target = mapping[edge.target];
|
||||
});
|
||||
|
||||
return const_begin + std::distance(begin, center);
|
||||
}
|
||||
@@ -93,13 +100,13 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
scc_algo.Run();
|
||||
|
||||
// Map Edges to Sccs
|
||||
const auto in_small = [&scc_algo, small_component_size](const NodeID node_id) {
|
||||
return scc_algo.GetComponentSize(scc_algo.GetComponentID(node_id)) <= small_component_size;
|
||||
};
|
||||
const auto in_small = [&scc_algo, small_component_size](const NodeID node_id)
|
||||
{ return scc_algo.GetComponentSize(scc_algo.GetComponentID(node_id)) <= small_component_size; };
|
||||
|
||||
const constexpr std::size_t small_component_id = -1;
|
||||
std::unordered_map<std::size_t, std::size_t> component_map;
|
||||
const auto transform_id = [&](const NodeID node_id) -> std::size_t {
|
||||
const auto transform_id = [&](const NodeID node_id) -> std::size_t
|
||||
{
|
||||
if (in_small(node_id))
|
||||
return small_component_id;
|
||||
else
|
||||
@@ -111,16 +118,19 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
mapping[node.original_id] = component_map[transform_id(node.original_id)]++;
|
||||
|
||||
// needs to remove edges, if we should ever switch to directed graphs here
|
||||
std::stable_sort(
|
||||
bisection_graph.Begin(), bisection_graph.End(), [&](const auto &lhs, const auto &rhs) {
|
||||
return transform_id(lhs.original_id) < transform_id(rhs.original_id);
|
||||
});
|
||||
std::stable_sort(bisection_graph.Begin(),
|
||||
bisection_graph.End(),
|
||||
[&](const auto &lhs, const auto &rhs)
|
||||
{ return transform_id(lhs.original_id) < transform_id(rhs.original_id); });
|
||||
|
||||
// remap all remaining edges
|
||||
std::for_each(bisection_graph.Begin(), bisection_graph.End(), [&](const auto &node) {
|
||||
for (auto &edge : bisection_graph.Edges(node))
|
||||
edge.target = mapping[edge.target];
|
||||
});
|
||||
std::for_each(bisection_graph.Begin(),
|
||||
bisection_graph.End(),
|
||||
[&](const auto &node)
|
||||
{
|
||||
for (auto &edge : bisection_graph.Edges(node))
|
||||
edge.target = mapping[edge.target];
|
||||
});
|
||||
|
||||
std::vector<BisectionGraphView> views;
|
||||
auto last = bisection_graph.CBegin();
|
||||
@@ -139,7 +149,8 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
}
|
||||
views.push_back(BisectionGraphView(bisection_graph, last, bisection_graph.CEnd()));
|
||||
|
||||
bool has_small_component = [&]() {
|
||||
bool has_small_component = [&]()
|
||||
{
|
||||
for (std::size_t i = 0; i < scc_algo.GetNumberOfComponents(); ++i)
|
||||
if (scc_algo.GetComponentSize(i) <= small_component_size)
|
||||
return true;
|
||||
@@ -154,7 +165,8 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s
|
||||
// ceil(log_2(components))
|
||||
scc_levels = ceil(log(views.size()) / log(2.0));
|
||||
|
||||
const auto conscutive_component_id = [&](const NodeID nid) {
|
||||
const auto conscutive_component_id = [&](const NodeID nid)
|
||||
{
|
||||
const auto component_id = transform_id(nid);
|
||||
const auto itr = ordered_component_ids.find(component_id);
|
||||
BOOST_ASSERT(itr != ordered_component_ids.end());
|
||||
|
||||
Reference in New Issue
Block a user