Git Product home page Git Product logo

held-karp's Introduction

Held-Karp
=========

Implementation of [Held-Karp](https://en.wikipedia.org/wiki/Held-Karp_algorithm),
an algorithm that solves the Traveling Salesman Problem using dynamic
programming with memoization.

Held-Karp solves the problem by calculating lowest cost on subsets of the
larger problem, and re-uses the intermediate results. Its runtime is
O(n^2 * 2^n), and it requires O(2^n * n) space.


Usage
-----

The implementation comes with a distance matrix generator taking an input size:

   $ python held-karp.py 5
     0 49 34 96 74
    49  0 10 94 43
    34 10  0 21  6
    96 94 21  0 70
    74 43  6 70  0
   
   (215, [0, 3, 2, 4, 1])

It is also possible to supply a distance matrix in a CSV format:

   $ python held-karp.py ex.csv
     0  2  9 10
     1  0  6  4
    15  7  0  8
     6  3 12  0
   
   (21, [0, 2, 3, 1])

held-karp's People

Contributors

carlekerot avatar

Watchers

James Cloos avatar Þorvaldur Rúnarsson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.