Repository navigation
Conversation
`GreedyColoringAlgorithm(order; recoloring_iterations=0)` improves the coloring of each order with passes of Culberson's iterated greedy algorithm: the vertices are recolored greedily in an order where the vertices of each color class are consecutive, which never increases the number of colors. The classes are ordered by decreasing color in odd passes and by decreasing size in even passes. This option only affects row and column colorings. Assisted-by: Claude Code (Opus 5.5)
`QuotientColoringAlgorithm(classes, algo)` gives all columns (rows) with the same class label the same color. The conflict pattern of the classes (`quotient_pattern`, with duplicate rows removed) is colored by `algo`, by default `GreedyColoringAlgorithm(; recoloring_iterations=30)`. This exploits translation structure, e.g., of discretizations on structured meshes, with classes given by the local index in the element and the position of the element in a small periodic cell. Assisted-by: Claude Code (Opus 5.5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #345 +/- ##
==========================================
+ Coverage 99.17% 99.19% +0.02%
==========================================
Files 22 23 +1
Lines 2304 2365 +61
==========================================
+ Hits 2285 2346 +61
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vchuravy
marked this pull request as ready for review
October 10, 2026 14:31
This branch has not been deployed
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.
Stacked on #344 (iterated greedy recoloring), which this PR needs for its default. The diff of this PR alone is the last commit, 640a728.
Adds
QuotientColoringAlgorithm(classes, algo), a column/row coloring in which all columns (rows) with the same class label get the same color:Two classes conflict if any of their columns have a nonzero in a common row.
quotient_patternbuilds the conflict pattern of the classes (classes × distinct rows), andalgocolors its columns. The class colors are then expanded to the columns. Columns of the same class must be structurally orthogonal; otherwise anArgumentErroris thrown. The algorithm plugs in through the ADTypes interface (ADTypes.column_coloring/row_coloring), socoloringchecks the result like any otherADTypes.AbstractColoringAlgorithm.Motivation: for discretizations on structured meshes, greedy colorings of the full pattern miss the translation structure, and recoloring does not help there (see #344: the greedy coloring is already a fixed point). Labeling each column by its local index in the element and the position of the element modulo a small periodic cell (e.g., 5 × 5 elements) gives a conflict pattern with few columns and very few distinct rows (49 for the examples below), so many recoloring passes are cheap. Number of column colors:
*
GreedyColoringAlgorithm((NaturalOrder(), LargestFirst(), SmallestLast(), IncidenceDegree(), DynamicLargestFirst()))on the full pattern.The order of the class coloring barely matters (natural, largest first and the five orders above all give 5 / 80 with 30 passes), but recoloring does. The cell must fit the stencil: for the 5-point stencil, 3 × 3 and 4 × 4 cells cannot hold the optimal period-5 coloring (8 colors for the Laplacian with a 4 × 4 cell, 144 = 9 × 16 for the DG-like pattern with a 3 × 3 cell). The docstring says so.
Changes
src/quotient.jl:QuotientColoringAlgorithm(exported, in the API docs, with a doctest),quotient_pattern(dev docs), andADTypes.column_coloring/row_coloringmethodstest/quotient.jl: the quotient pattern (deduplication, errors), the Laplacian with optimal 5 colors for column and row partitions (withcompress/decompress), classes constant on cells, trivial classes equal to greedy, an error for a too small cell, and a block pattern reaching its lower boundLocally on Julia 1.11:
quotient.jl,adtypes.jl,constant.jl,order.jl, JET, doctests and Aqua's undocumented-names check pass.Draft because it depends on #344. Open questions: the name, the default
algo, and whether a helper for block classes (local index × cell label) belongs in SMC or in user code.🤖 Generated with Claude Code