Skip to content

Commit e21de44

Browse files
committed
fix(tests): increase graph size to trigger modular degree heuristic
The test "should use degree heuristic for large graphs with distinct degrees" was failing with: expected 'modular' to be 'unconstrained' Root cause: Test created a 15-node path graph, but the degree heuristic only activates for graphs with >= 25 nodes (line 171 in perfect-variants.ts). With 15 nodes, the exhaustive check ran instead, correctly determining the path graph is modular. Fix: Increased graph size from 15 to 25 vertices to trigger the heuristic. The path graph has: - 2 endpoints with degree 1 - 23 middle vertices with degree 2 - Not all distinct degrees → heuristic returns "unconstrained" This properly tests the intended behavior: for large graphs without all distinct degrees, the heuristic returns "unconstrained" rather than running the expensive exhaustive module check.
1 parent 001b3d8 commit e21de44

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/analyzer/perfect-variants.unit.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ describe("computeModular", () => {
223223
});
224224

225225
it("should use degree heuristic for large graphs with distinct degrees", () => {
226-
// Create a path of 15 vertices (all have degree 1 or 2, but positions differ)
227-
const vertices = Array.from({ length: 15 }, (_, index) => `V${index}`);
226+
// Create a path of 25 vertices (triggers heuristic at >= 25 nodes)
227+
// Endpoints have degree 1, middle vertices degree 2 (not all distinct)
228+
const vertices = Array.from({ length: 25 }, (_, index) => `V${index}`);
228229
const edges: Array<[string, string]> = [];
229-
for (let index = 0; index < 14; index++) {
230+
for (let index = 0; index < 24; index++) {
230231
edges.push([`V${index}`, `V${index + 1}`]);
231232
}
232233

0 commit comments

Comments
 (0)