Skip to content

refactor(shm): decompose label_propagation.h into composable building blocks#131

Open
DanielSeemaier wants to merge 2 commits intomainfrom
claude/blissful-ride
Open

refactor(shm): decompose label_propagation.h into composable building blocks#131
DanielSeemaier wants to merge 2 commits intomainfrom
claude/blissful-ride

Conversation

@DanielSeemaier
Copy link
Member

No description provided.

DanielSeemaier and others added 2 commits March 16, 2026 16:50
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant