You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The codebase currently has TravelingSalesman<G, W> (originally implemented as HamiltonianCycle, then renamed). Several open issues reference Hamiltonian Circuit (#519, #520) and Hamiltonian Path (#432, #433, #435, #436) as source problems for reductions to other targets, but neither exists as a standalone model yet.
This issue discusses whether we need separate models and how trivial the reductions between them are.
Problem Definitions
Problem
Visits all vertices
Returns to start
Weighted / Optimization
Hamiltonian Path
Yes
No
No (decision: does such a path exist?)
Hamiltonian Circuit
Yes
Yes
No (decision: does such a circuit exist?)
Traveling Salesman
Yes
Yes
Yes (minimize total edge weight)
Hamiltonian Path: Given graph G, does there exist a path visiting every vertex exactly once?
Hamiltonian Circuit (Cycle): Given graph G, does there exist a cycle visiting every vertex exactly once?
Traveling Salesman (TSP): Given a weighted graph G, find the minimum-weight Hamiltonian circuit.
Do We Need Separate Models?
The current TravelingSalesman subsumes Hamiltonian Circuit (set all weights to 1, check if optimal tour cost = n). But:
Hamiltonian Circuit is a SatisfactionProblem (Metric = bool), while TravelingSalesman is an OptimizationProblem. They have different trait implementations and solver interfaces (find_satisfying vs find_best).
Hamiltonian Path is structurally different — no return-to-start requirement, different configuration space.
HamiltonianCircuit<G> — SatisfactionProblem on graphs, binary variable per edge
HamiltonianPath<G> — SatisfactionProblem on graphs, binary variable per edge
Reductions Between Them
Hamiltonian Circuit → Traveling Salesman
Triviality: Near-trivial (embedding). Given graph G, create TSP instance with weight 1 for edges in G and weight n+1 for non-edges (on complete graph). G has a Hamiltonian circuit iff optimal TSP cost = n. This is a standard textbook reduction but requires constructing the complete graph and choosing weights — not a mere type cast.
Hamiltonian Path → Hamiltonian Circuit
Triviality: Simple but non-trivial. Add a dummy vertex connected to all existing vertices. G has a Hamiltonian path iff the augmented graph has a Hamiltonian circuit (the dummy vertex "closes" the path). Overhead: 1 extra vertex, n extra edges. Simple construction, but real work is done.
Hamiltonian Path → Traveling Salesman
Triviality: Simple, composes the above two. Add dummy vertex + complete graph construction + weight assignment. Could be implemented directly or as a composite reduction.
Hamiltonian Circuit → Hamiltonian Path
Triviality: Slightly more involved. For each edge (u,v) in G, check if G minus (u,v) has a Hamiltonian path from u to v. This is a Turing reduction (polynomial number of oracle calls), not a single many-one reduction. A many-one reduction exists but requires gadget construction. Less trivial than the reverse direction.
Questions for Discussion
Should HamiltonianCircuit be a thin wrapper around TravelingSalesman (delegating to it internally) or a fully independent model?
For the Path → Circuit reduction (dummy vertex), is O(n) overhead small enough to warrant a "simple" label, or should we treat it like any other rule?
Should we implement the direct Path → TSP reduction, or rely on the composite path Path → Circuit → TSP?
Are there other reductions from/to these problems we should prioritize?
Context
The codebase currently has
TravelingSalesman<G, W>(originally implemented asHamiltonianCycle, then renamed). Several open issues reference Hamiltonian Circuit (#519, #520) and Hamiltonian Path (#432, #433, #435, #436) as source problems for reductions to other targets, but neither exists as a standalone model yet.This issue discusses whether we need separate models and how trivial the reductions between them are.
Problem Definitions
Do We Need Separate Models?
The current
TravelingSalesmansubsumes Hamiltonian Circuit (set all weights to 1, check if optimal tour cost = n). But:SatisfactionProblem(Metric = bool), whileTravelingSalesmanis anOptimizationProblem. They have different trait implementations and solver interfaces (find_satisfyingvsfind_best).Proposal: Add two new models:
HamiltonianCircuit<G>—SatisfactionProblemon graphs, binary variable per edgeHamiltonianPath<G>—SatisfactionProblemon graphs, binary variable per edgeReductions Between Them
Hamiltonian Circuit → Traveling Salesman
Triviality: Near-trivial (embedding). Given graph G, create TSP instance with weight 1 for edges in G and weight n+1 for non-edges (on complete graph). G has a Hamiltonian circuit iff optimal TSP cost = n. This is a standard textbook reduction but requires constructing the complete graph and choosing weights — not a mere type cast.
Hamiltonian Path → Hamiltonian Circuit
Triviality: Simple but non-trivial. Add a dummy vertex connected to all existing vertices. G has a Hamiltonian path iff the augmented graph has a Hamiltonian circuit (the dummy vertex "closes" the path). Overhead: 1 extra vertex, n extra edges. Simple construction, but real work is done.
Hamiltonian Path → Traveling Salesman
Triviality: Simple, composes the above two. Add dummy vertex + complete graph construction + weight assignment. Could be implemented directly or as a composite reduction.
Hamiltonian Circuit → Hamiltonian Path
Triviality: Slightly more involved. For each edge (u,v) in G, check if G minus (u,v) has a Hamiltonian path from u to v. This is a Turing reduction (polynomial number of oracle calls), not a single many-one reduction. A many-one reduction exists but requires gadget construction. Less trivial than the reverse direction.
Questions for Discussion
HamiltonianCircuitbe a thin wrapper aroundTravelingSalesman(delegating to it internally) or a fully independent model?References