Skip to content

Comments

Fix #47: Add HamiltonianCycle model#57

Merged
GiggleLiu merged 4 commits intomainfrom
issue-47-hamiltonian-cycle
Feb 13, 2026
Merged

Fix #47: Add HamiltonianCycle model#57
GiggleLiu merged 4 commits intomainfrom
issue-47-hamiltonian-cycle

Conversation

@GiggleLiu
Copy link
Contributor

[action]

Summary

  • Add HamiltonianCycle<G, W> optimization model: finds minimum-weight cycle visiting every vertex exactly once
  • Edge-based binary variables (dims = [2; num_edges]), with validity check for degree-2, connectivity, and edge count
  • Follows MaximumMatching pattern (edge weights, from_graph constructors, is_weighted())
  • Includes paper documentation with problem-def and display-name entry

Closes #47

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 95.91837% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.93%. Comparing base (d8eec69) to head (53c68d0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/models/graph/traveling_salesman.rs 92.40% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
- Coverage   96.94%   96.93%   -0.02%     
==========================================
  Files         174      176       +2     
  Lines       25043    25337     +294     
==========================================
+ Hits        24278    24560     +282     
- Misses        765      777      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GiggleLiu and others added 2 commits February 13, 2026 21:55
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new graph optimization model, HamiltonianCycle<G, W>, to represent the minimum-weight Hamiltonian cycle problem, along with unit tests and documentation/schema registration so it appears in exported schemas and the paper.

Changes:

  • Introduces HamiltonianCycle model (edge-based binary variables, validity check, objective evaluation, from_graph constructors) and exports it from graph/model modules and the crate prelude.
  • Adds comprehensive unit tests exercising construction, validation, evaluation, and brute-force solving on small instances.
  • Registers/updates documentation artifacts (problem schema JSON + paper display-name and problem-def) and adds an implementation plan document.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/models/graph/hamiltonian_cycle.rs New HamiltonianCycle model + schema registration + is_hamiltonian_cycle validator
src/models/graph/mod.rs Wires new model into the graph module and re-exports it
src/models/mod.rs Re-exports HamiltonianCycle at the models module level and updates category docs
src/lib.rs Adds HamiltonianCycle to the crate prelude
src/unit_tests/models/graph/hamiltonian_cycle.rs New unit tests for the model + brute-force solver behavior
docs/src/reductions/problem_schemas.json Adds schema entry for HamiltonianCycle
docs/paper/reductions.typ Adds paper display-name + formal problem definition
docs/plans/2026-02-13-hamiltonian-cycle-model.md Adds implementation plan document for the model

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

]

#problem-def("HamiltonianCycle")[
Given an undirected graph $G=(V,E)$ with edge weights $w: E -> RR$, find a cycle visiting every vertex exactly once that minimizes $sum_(e in C) w(e)$.
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem definition uses C in the objective (sum_(e in C) w(e)) but doesn't define what C is. Please define C (e.g., C ⊆ E is the edge set of a Hamiltonian cycle / a cycle visiting every vertex exactly once) so the statement is self-contained and unambiguous.

Suggested change
Given an undirected graph $G=(V,E)$ with edge weights $w: E -> RR$, find a cycle visiting every vertex exactly once that minimizes $sum_(e in C) w(e)$.
Given an undirected graph $G=(V,E)$ with edge weights $w: E -> RR$, find an edge set $C subset.eq E$ that forms a cycle visiting every vertex exactly once and minimizes $sum_(e in C) w(e)$.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@GiggleLiu GiggleLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weighted HamiltonianCycle is equivalent to TravelingSalesman problem. Please rename.

Resolve PR review comments: weighted HamiltonianCycle is equivalent to
the Traveling Salesman Problem, so rename accordingly. Also fix problem
definition to properly define the edge set C.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit 715ae78 into main Feb 13, 2026
3 checks passed
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.

[Model] HamiltonianCycle

1 participant