{"id":15620259,"url":"https://github.com/nschloe/tspsolve","last_synced_at":"2025-06-17T19:35:27.493Z","repository":{"id":62585417,"uuid":"140282337","full_name":"nschloe/tspsolve","owner":"nschloe","description":"Solution algorithms for the travelling salesman problem.","archived":false,"fork":false,"pushed_at":"2018-07-09T15:50:42.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T08:08:17.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nschloe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-09T12:30:03.000Z","updated_at":"2021-07-05T05:35:41.000Z","dependencies_parsed_at":"2022-11-03T22:02:14.187Z","dependency_job_id":null,"html_url":"https://github.com/nschloe/tspsolve","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nschloe/tspsolve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftspsolve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftspsolve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftspsolve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftspsolve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nschloe","download_url":"https://codeload.github.com/nschloe/tspsolve/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nschloe%2Ftspsolve/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260427404,"owners_count":23007502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T09:00:53.951Z","updated_at":"2025-06-17T19:35:22.476Z","avatar_url":"https://github.com/nschloe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tspsolve\n\n[![CircleCI](https://img.shields.io/circleci/project/github/nschloe/tspsolve/master.svg)](https://circleci.com/gh/nschloe/tspsolve/tree/master)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/tspsolve.svg)](https://codecov.io/gh/nschloe/tspsolve)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![PyPi Version](https://img.shields.io/pypi/v/tspsolve.svg)](https://pypi.org/project/tspsolve)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/tspsolve.svg?logo=github\u0026label=Stars)](https://github.com/nschloe/tspsolve)\n\nAlgorithms for the [traveling salesman problem\n(TSP)](https://en.wikipedia.org/wiki/Travelling_salesman_problem) in Python.\n\nImplemented so far:\n\n  * Nearest neighbor algorithm\n    ```python\n    import tspsolve\n\n    # Create matrix of distances d\n    path = tspsolve.nearest_neighbor(d)\n    ```\n\n  * [2-opt](https://en.wikipedia.org/wiki/2-opt) improvement\n    ```python\n    import tspsolve\n\n    # Create matrix of distances d and an initial path\n    new_path = tspsolve.two_opt(d, path, verbose=True)\n    ```\n\nFor [Euclidiean\nTSP](https://en.wikipedia.org/wiki/Travelling_salesman_problem#Euclidean_TSP), the\ndistance matrix can be computed efficiently with\n```python\ndx = numpy.subtract.outer(x, x)\ndy = numpy.subtract.outer(y, y)\nd = numpy.sqrt(dx ** 2 + dy ** 2)\n```\n\n### Installation\n\ntspsolve is [available from the Python Package\nIndex](https://pypi.org/project/tspsolve/), so simply type\n```\npip install -U tspsolve\n```\nto install or upgrade.\n\n### Testing\n\nTo run the tspsolve unit tests, check out this repository and type\n```\npytest\n```\n\n### Distribution\n\nTo create a new release\n\n1. bump the `__version__` number,\n\n2. publish to PyPi and GitHub:\n    ```\n    make publish\n    ```\n\n### License\n\ntspsolve is published under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnschloe%2Ftspsolve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnschloe%2Ftspsolve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnschloe%2Ftspsolve/lists"}