{"id":18864817,"url":"https://github.com/rshipp/tsp","last_synced_at":"2025-04-14T13:21:51.565Z","repository":{"id":26391096,"uuid":"29840634","full_name":"rshipp/tsp","owner":"rshipp","description":"Defund the Police.","archived":false,"fork":false,"pushed_at":"2020-06-14T23:56:54.000Z","size":75,"stargazers_count":19,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T13:21:44.041Z","etag":null,"topics":["algorithm","drop-ice","graph","python","traveling-salesman","traveling-salesperson","travelling-salesman-problem","tsp","tsp-solver"],"latest_commit_sha":null,"homepage":"https://blacklivesmatters.carrd.co/#donate","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/rshipp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"rshipp","tidelift":null,"community_bridge":null,"custom":null}},"created_at":"2015-01-26T02:01:34.000Z","updated_at":"2024-02-15T23:11:40.000Z","dependencies_parsed_at":"2022-08-20T17:40:59.890Z","dependency_job_id":null,"html_url":"https://github.com/rshipp/tsp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rshipp%2Ftsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rshipp%2Ftsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rshipp%2Ftsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rshipp%2Ftsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rshipp","download_url":"https://codeload.github.com/rshipp/tsp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886334,"owners_count":21177645,"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":["algorithm","drop-ice","graph","python","traveling-salesman","traveling-salesperson","travelling-salesman-problem","tsp","tsp-solver"],"created_at":"2024-11-08T04:44:09.956Z","updated_at":"2025-04-14T13:21:51.523Z","avatar_url":"https://github.com/rshipp.png","language":"Python","readme":"# Traveling Salesman Problem\n\n[![Drop ICE](drop.png)](https://twitter.com/githubbers/status/1182017616740663296)\n\nTwo implementations of solutions to the Traveling Salesman Problem in Python 3.\n\nThe first solution brute forces all permutations and is guaranteed to find\nthe optimal solution for visiting all points.\n\nThe second solution is \"nearest neighbor\", which is much faster, but is not\nguaranteed to find the optimal solution. In some edge cases, it finds very poor\nsolutions.\n\nMy implementations of these algorithms display about O(n!) and 1/4 O(n^2) time,\nrespectively.\n\n## Usage\n\nIf you want to run the comparisons yourself, just go\n\n    ./run.sh\n\nOr, if you want to run individual tests, just use `./optimaltsp.py FILENAME` or\n`./nearestneighbor.py FILENAME`.\n\n## Graphs\n\nHere are some quick runtime graphs, courtesy of [WolframAlpha](http://www.wolframalpha.com).\n\n### Optimal\n\n[![optimal graph](optimal.png \"x-axis is input points; y-axis is seconds\")](http://www.wolframalpha.com/input/?i=plot+%286%2C+0.02%29%2C+%288%2C+1.0%29%2C+%289%2C+9.9%29%2C+%2810%2C+184.1%29)\n\n### Nearest neighbor\n\n[![nearest neighbor graph](nn.png \"x-axis is input points; y-axis is seconds\")](http://www.wolframalpha.com/input/?i=plot%20%289%2C%200%29%2C%20%281500%2C%205%29%2C%20%283000%2C%2019%29%2C%20%286000%2C%20149%29)\n\n## Data\n\n","funding_links":["https://ko-fi.com/rshipp"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frshipp%2Ftsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frshipp%2Ftsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frshipp%2Ftsp/lists"}