Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:43:37+00:00 2026-05-30T14:43:37+00:00

I am interested in solving the TSP for (small) grid graphs. Any sort of

  • 0

I am interested in solving the TSP for (small) grid graphs. Any sort of library will do for me, but this seems to be harder than expected. I tried a couple of solvers I found out there (including concorde), but they all seem to have problems when the triangle inequality does not hold.

For instance, I would like the solver to output the tour (0, 1, 2, 1, 4, 3) for the graph (with unit edge weights) below:

0-1-2
| |
3-4

In this particular case, I told concorde that the edge (2, 4) had weight 1000 and concorde promptly produced the tour (0, 1, 2, 4, 3) of cost 1004. This is clearly not what I am looking for.

Ideally, there would be some simple (possibly brute force) implementation in Java, but anything which works will actually do. Can anyone point me to some code or do I really have to go an implement this myself?

Edit: also, it is important that I get an exact solution, not some approximation.

Edit2: indeed, this does not seem to be TSP. What I am trying to find is a shortest closed walk which visits all vertices.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:43:39+00:00Added an answer on May 30, 2026 at 2:43 pm

    Your difficulty is not the triangle inequality. The difficulty has to do with the fact that the solution you’re expecting is not a valid TSP tour.

    The TSP seeks a Hamiltonian cycle; that is, a cycle that visits each vertex exactly once. Your solution, (0, 1, 2, 1, 4, 3), visits vertex 1 twice.

    If that’s the solution you’re seeking, then the the problem you’re trying to solve is not the Travelling Salesman Problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: I'm more interested in understanding general Go concepts/patterns, rather than solving this contrived
UPDATE: Perhaps this wasn't clear from my original post, but I'm mainly interested in
This may be a hopelessly vague question. But I am interested to hear whatever
I am particularly interested in Document Libraries, but in terms of general SharePoint lists,
I'm interested in building a derivative calculator. I've racked my brains over solving the
Im interested in implementing a JQuery solution for a Panel Selector that seems very
This is fairly 'math-y' but I'm posting here because it's a Project Euler problem,
Apologies for the horrible title but I've no idea how to describe this easily.
Does anyone have any workable strategy for solving casting/upcasting questions? I understand when upcasting
Interested if anyone has used VSTS Database Edition extensively and, if so, which features

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.