Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/kaminpar-shm/kaminpar.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ class Graph {

[[nodiscard]] bool sorted() const;

void set_level(int level);
[[nodiscard]] int level() const;

[[nodiscard]] AbstractGraph *underlying_graph();
[[nodiscard]] const AbstractGraph *underlying_graph() const;

Expand All @@ -707,6 +710,7 @@ class Graph {

private:
std::unique_ptr<AbstractGraph> _underlying_graph;
int _level = 0;
};

[[nodiscard]] Graph compress(
Expand Down
13 changes: 8 additions & 5 deletions kaminpar-shm/coarsening/abstract_cluster_coarsener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ bool AbstractClusterCoarsener::keep_allocated_memory() const {
return level() >= _c_ctx.clustering.max_mem_free_coarsening_level;
}

void AbstractClusterCoarsener::compute_clustering_for_current_graph(
StaticArray<NodeID> &clustering
void AbstractClusterCoarsener::compute_clustering_for_current_graph(StaticArray<NodeID> &clustering
) {
const bool free_allocated_memory = !keep_allocated_memory();
const NodeWeight total_node_weight = current().total_node_weight();
Expand Down Expand Up @@ -174,9 +173,13 @@ void AbstractClusterCoarsener::contract_current_graph_and_push(StaticArray<NodeI
START_HEAP_PROFILER("Contract graph");
START_TIMER("Contract graph");

_hierarchy.push_back(
contract_clustering(current(), std::move(clustering), _c_ctx.contraction, _contraction_m_ctx)
);
_hierarchy.push_back([&] {
auto c_graph = contract_clustering(
current(), std::move(clustering), _c_ctx.contraction, _contraction_m_ctx
);
c_graph->get().set_level(level() + 1);
return c_graph;
}());

auto project_communities = [&](const std::size_t fine_n,
const NodeID *fine_ptr,
Expand Down
9 changes: 9 additions & 0 deletions kaminpar-shm/datastructures/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace kaminpar::shm {

Graph::Graph(std::unique_ptr<AbstractGraph> graph) : _underlying_graph(std::move(graph)) {}

Graph::~Graph() = default;

Graph::Graph(Graph &&) noexcept = default;
Expand Down Expand Up @@ -53,6 +54,14 @@ bool Graph::sorted() const {
return _underlying_graph->sorted();
}

void Graph::set_level(const int level) {
_level = level;
}

int Graph::level() const {
return _level;
}

AbstractGraph *Graph::underlying_graph() {
return _underlying_graph.get();
}
Expand Down
3 changes: 2 additions & 1 deletion kaminpar-shm/refinement/jet/jet_refiner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ template <typename Graph> class JetRefinerImpl {
SCOPED_TIMER("Jet Refiner");
SCOPED_TIMER("Initialization");

const bool is_coarse_level = p_graph.graph().n() < _ctx.partition.n;
const bool is_coarse_level = p_graph.graph().level() > 0;

if (is_coarse_level) {
_num_rounds = _ctx.refinement.jet.num_rounds_on_coarse_level;
_initial_gain_temp = _ctx.refinement.jet.initial_gain_temp_on_coarse_level;
Expand Down
Loading