refactor(shm): decompose label_propagation.h into composable building blocks#131
Open
DanielSeemaier wants to merge 2 commits intomainfrom
Open
refactor(shm): decompose label_propagation.h into composable building blocks#131DanielSeemaier wants to merge 2 commits intomainfrom
DanielSeemaier wants to merge 2 commits intomainfrom
Conversation
… blocks
The 2179-line CRTP-based label_propagation.h monolith is replaced with
ten focused, independently testable components in kaminpar-shm/label_propagation/:
- config.h – LabelPropagationConfig, ClusterSelectionState, Bucket types
- cluster_ops.h – NonatomicClusterVectorRef, OwnedRelaxedClusterWeightVector
- active_set.h – ActiveSet<kEnabled> with compile-time enable/disable
- cluster_relabeling.h – free-standing relabel_clusters() compaction utility
- two_hop_clustering.h – isolated-node and two-hop matching/clustering utilities
- chunk_random_iteration.h – ChunkRandomIterator<Config> standalone class
- in_order_iteration.h – InOrderIterator standalone class
- simple_gain_selection.h – SimpleGainClusterSelection for the clusterer
- overload_aware_selection.h – OverloadAwareClusterSelection for the refiner
- node_processor.h – LPNodeProcessor<Graph, ClusterOps, Selection, Config>
the core per-node LP engine
Both SHM consumers are rewritten to compose these blocks (has-a, no CRTP):
- lp_clusterer.cc: LPClusteringOps + SimpleGainClusterSelection + LPNodeProcessor
- lp_refiner.cc: LPRefinerOps + OverloadAwareClusterSelection + LPNodeProcessor
Unit tests are added for all building blocks (31 new test cases, 295 total).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ate() Both ChunkRandomIterator and InOrderIterator now expose the same interface: - prepare(graph, from, to, max_degree) — initialize/store iteration state - clear() — reset state when the graph changes - iterate(graph, max_degree, ...) — run one LP iteration ChunkRandomIterator::prepare() encapsulates the former if (empty()) init_chunks(...); shuffle_chunks(); pattern that was repeated verbatim in both consumers. InOrderIterator is converted from a static-method utility to a proper stateful class (templated on Config for kMinChunkSize), storing the iteration range set by prepare() and removing the RatingMap template parameter that was unused. Both consumers now call _iterator.prepare(...) and _iterator.iterate(...) with identical call sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.