Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #570 +/- ##
==========================================
+ Coverage 96.37% 96.49% +0.11%
==========================================
Files 200 206 +6
Lines 27871 28301 +430
==========================================
+ Hits 26861 27309 +448
+ Misses 1010 992 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add GraphPartitioning (Minimum Bisection) problem model - Single type param G (unweighted, counts crossing edges) - Balanced bisection: requires |A| = |B| = n/2 (even n) - Direction: Minimize - Register in CLI (dispatch, aliases, create command) - Add unit tests (11 tests covering all cases) - Add problem-def entry in paper with CeTZ visualization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Assert exact cut value in unbalanced_invalid test - Warn and round up when random generation gets odd vertex count Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new NP-hard graph model, GraphPartitioning (Minimum Bisection), to the problemreductions model catalog, with supporting CLI wiring, tests, and paper documentation.
Changes:
- Introduce
GraphPartitioning<SimpleGraph>model with schema registration, variants, and evaluation logic. - Add CLI support (alias resolution, JSON dispatch serialization/deserialization, and
pred createsupport including random instance generation). - Add unit tests and paper docs entry for Graph Partitioning.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/models/graph/graph_partitioning.rs |
New GraphPartitioning model implementation, schema registration, variants, and tests module hook. |
src/models/graph/mod.rs |
Registers/exposes the new graph model in the graph models module. |
src/models/mod.rs |
Re-exports GraphPartitioning from the top-level models module. |
src/lib.rs |
Exposes GraphPartitioning via the crate prelude. |
src/unit_tests/models/graph/graph_partitioning.rs |
Adds unit tests covering evaluation, direction, serialization, and brute-force solving. |
problemreductions-cli/src/problem_name.rs |
Adds CLI alias mapping for graphpartitioning. |
problemreductions-cli/src/dispatch.rs |
Adds load/serialize dispatch cases for GraphPartitioning<SimpleGraph>. |
problemreductions-cli/src/commands/create.rs |
Adds pred create GraphPartitioning support (explicit graph + random generation). |
docs/paper/reductions.typ |
Adds paper definition + figure entry for Graph Partitioning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Check balanced: exactly n/2 vertices in partition 1 | ||
| let count_ones: usize = config.iter().sum(); |
There was a problem hiding this comment.
count_ones is computed as config.iter().sum(), which treats any value >1 as multiple vertices in partition 1. This allows invalid assignments (e.g., a 2 value) to pass the balance check and produce incorrect cut sizes. Consider validating config is binary (all values <2) and/or counting ones via filter(|&&x| x == 1).count() after a domain check.
| // Check balanced: exactly n/2 vertices in partition 1 | |
| let count_ones: usize = config.iter().sum(); | |
| // Optional: ensure configuration length matches number of vertices | |
| if config.len() != n { | |
| return SolutionSize::Invalid; | |
| } | |
| // Check balanced: exactly n/2 vertices in partition 1, and ensure binary labels | |
| let mut count_ones: usize = 0; | |
| for &x in config.iter() { | |
| if x > 1 { | |
| // Invalid label (must be 0 or 1) | |
| return SolutionSize::Invalid; | |
| } | |
| if x == 1 { | |
| count_ones += 1; | |
| } | |
| } |
| inventory::submit! { | ||
| ProblemSchemaEntry { | ||
| name: "GraphPartitioning", | ||
| module_path: module_path!(), | ||
| description: "Find minimum cut balanced bisection of a graph", | ||
| fields: &[ | ||
| FieldInfo { name: "graph", type_name: "G", description: "The undirected graph G=(V,E)" }, | ||
| ], | ||
| } | ||
| } |
There was a problem hiding this comment.
This repo appears to treat docs/src/reductions/reduction_graph.json as an auto-generated artifact (see examples/export_graph.rs) and it currently does not include GraphPartitioning. After adding a new model, please regenerate and commit the updated JSON so docs/tooling that consume it stay in sync.
| let mut cut = 0i32; | ||
| for (u, v) in self.graph.edges() { | ||
| if config[u] != config[v] { | ||
| cut += 1; | ||
| } |
There was a problem hiding this comment.
evaluate indexes config[u]/config[v] while iterating edges, but it never checks config.len() == num_vertices(). For shorter configs this will panic at runtime instead of returning SolutionSize::Invalid. Add a length check (and consider using get() like other graph models) before indexing.
…ng::evaluate Address Copilot review comments: validate config length matches vertex count and use filter-based counting instead of sum for correct binary detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR #599 (KSat→SubsetSum): Fix imprecise Karp 1972 attribution — the direct 3-SAT→SubsetSum digit encoding follows Sipser (2012, Thm 7.56) and CLRS (2022, §34.5.5), not Karp's original reduction tree. Add bib entries for both textbooks. PR #570 (GraphPartitioning): Add proper @Citations for Garey, Johnson & Stockmeyer (1976) and Arora, Rao & Vazirani (2009) instead of plain-text references. Add bib entries for both papers. Regenerate problem_schemas.json and reduction_graph.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address issue review comments for #126 and #117 PR #599 (KSat→SubsetSum): Fix imprecise Karp 1972 attribution — the direct 3-SAT→SubsetSum digit encoding follows Sipser (2012, Thm 7.56) and CLRS (2022, §34.5.5), not Karp's original reduction tree. Add bib entries for both textbooks. PR #570 (GraphPartitioning): Add proper @Citations for Garey, Johnson & Stockmeyer (1976) and Arora, Rao & Vazirani (2009) instead of plain-text references. Add bib entries for both papers. Regenerate problem_schemas.json and reduction_graph.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add FPT complexity citation for GraphPartitioning (#117) Address review comment: explicitly state that brute-force O*(2^n) is the best known unconditional exact algorithm, and cite Cygan et al. (STOC 2014 / SICOMP 2019) for the FPT result parameterized by bisection width. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use sort_by_key per clippy unnecessary_sort_by lint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add merge-with-main conflict resolution step to review-pipeline Add Step 1a between checkout and Copilot fixes to merge origin/main into the PR branch. Resolves simple conflicts automatically; aborts and reports for complex conflicts needing manual resolution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * update pipeline skills: eligibility-first sorting, merge-with-main project-pipeline: Reorder Steps 0c/0d so eligibility check (source and target models exist) runs before scoring. Only eligible issues get scored. review-pipeline: Add Step 1a to merge origin/main into the PR branch before fixing Copilot comments, catching conflicts early. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Add the GraphPartitioning (Minimum Bisection) problem model. Given an undirected graph with an even number of vertices, find a balanced partition into two equal halves minimizing the number of crossing edges.
Fixes #117