Skip to main content

A fast C++ implementation of the Held-Karp algorithm for solving TSP

Project description

toposolve

A fast C++ implementation of the Held-Karp algorithm for solving the Traveling Salesman Problem (TSP) for ring-reduce tours, with Python bindings. We solve a specific variant of TSP where the dist(i, j) is calculated as min(max(dist(i, k), dist(k, j)) for k in range(n)).

Installation

pip install toposolve

Usage

from toposolve import TSPSolver

# Create distance matrix
distances = [
    [0, 10, 15, 20],
    [10, 0, 35, 25],
    [15, 35, 0, 30],
    [20, 25, 30, 0]
]

# Create solver instance
solver = TSPSolver()

# Solve TSP
min_distance, path = solver.solve_tsp(distances)

print(f"Minimum distance: {min_distance}")
print(f"Optimal path: {path}")

Requirements

  • Python 3.6+
  • C++ compiler supporting C++17
  • CMake 3.18+

Building from source

git clone https://github.com/Jackmin801/toposolve
cd toposolve
pip install .

Running tests

pip install pytest
pytest tests/

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toposolve-0.1.17.tar.gz (5.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

toposolve-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (95.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

toposolve-0.1.17-cp312-cp312-macosx_11_0_arm64.whl (127.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

toposolve-0.1.17-cp312-cp312-macosx_10_13_x86_64.whl (127.4 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

toposolve-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (96.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

toposolve-0.1.17-cp311-cp311-macosx_11_0_arm64.whl (128.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

toposolve-0.1.17-cp311-cp311-macosx_10_9_x86_64.whl (128.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

toposolve-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (95.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

toposolve-0.1.17-cp310-cp310-macosx_11_0_arm64.whl (125.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

toposolve-0.1.17-cp310-cp310-macosx_10_9_x86_64.whl (125.5 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

toposolve-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (94.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

toposolve-0.1.17-cp39-cp39-macosx_11_0_arm64.whl (125.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

toposolve-0.1.17-cp39-cp39-macosx_10_9_x86_64.whl (125.7 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

toposolve-0.1.17-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (94.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

toposolve-0.1.17-cp38-cp38-macosx_11_0_arm64.whl (125.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

toposolve-0.1.17-cp38-cp38-macosx_10_9_x86_64.whl (125.3 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file toposolve-0.1.17.tar.gz.

File metadata

  • Download URL: toposolve-0.1.17.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for toposolve-0.1.17.tar.gz
Algorithm Hash digest
SHA256 539a1301ed36df5e2fbd0d3e1806f2c6cd7840c3527938647a61b0a7b53689f9
MD5 7d32c903493db79fb82536ee6c624591
BLAKE2b-256 515de24dd0bbbf9f508d9aa11120fdcc7b0e4caf1c1d401359495636470e0431

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b238dadaced7fe98638fcb595596619104724a66ba1205914d0faebb2a2081b
MD5 665fa6d12e82447610eaf96800dc756c
BLAKE2b-256 1e8e0d7b43f5c751490745bd25cf2cf1f1285627749e3ebfd2da131a9bbdac8c

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17666bdb0078cddcffc89cb9e7c0f0ce35007597b8a309f7b29c6a39a0fb6d8a
MD5 bd13cecb46efb34b439a561c3b30d9b9
BLAKE2b-256 443ba51dd6d756076853f1a6d18cc20761126b613a28a5ff9e37a113a546477b

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e158c666e1492832dba077eaea9c4bcd88fbb3f45b8bfde8a8f545d5de8212e2
MD5 a77ab2f00ff312bed2c16e282b826e7b
BLAKE2b-256 701e7028dbd313ba931c086ecb24856566fb34cd159d3bd305cf05fa6b66bb3b

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac94551501ca671d428c7ad435a50da5cd33f832c432c87e676f3ab8310bf19d
MD5 b0ac61128c3fb886c1398efc4ddb07c3
BLAKE2b-256 4f3bb6e6c863d06f8cb533068224f954b3b49722ba88cb6a0861fd62aefbc151

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baa9a76f54f295d8beb06559bd90c117c9a0c2f84aa4c9c661fb283a7529fd68
MD5 47d3e068135e4c9b9a541fa6b5ecd129
BLAKE2b-256 b9ab9e062fe4e58729594eda886ed464e4839232162e1ddbd0e36b5bcb61d664

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8b13cdf80823dd86dd75bda7f94418b5b093cbb4989a4a6f0956f2595b8a7be1
MD5 06804d2f8f52d08d5a20802410d552b8
BLAKE2b-256 58c0854d8b5cc5cb23d99720c28908e5eff587e1ec25c797ceac219bf5f0f3a7

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 141ba41c36e49ecd2280517031f4ef8c2c131b4fb93b85f38c10fead17974b7f
MD5 3a05e4c2f2eda833099cda473f18e6f7
BLAKE2b-256 6146062d43764ac1cf6fff3edde81295846d6191c43a103550ddf27472da49ca

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dda111813910145f97df62e34d30ad38c39df45539f129b57df0e6c51e52902b
MD5 6a29dd2d2defed991da9c2d0ac1bb7d3
BLAKE2b-256 ed4c90f3b00b1f381ead4394cb1a1391b8dcd2a043490b2f77ebf71609e24b91

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cc1a33e2438c29a29ccac4c957c6ffaf035b239b34f0e369f4665ed255b413c9
MD5 9334bc2d509da93b61ff699c5de22256
BLAKE2b-256 c40291db85f3ab2822377e90357b23783c5a1408cdb7c36f9f94a7d3db6783cc

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c23b65a9e88740df59acbf56dea8b86b693e0bf82b42aec8b55daa0328f28c67
MD5 2f829e352ed5dd10b1c424630eb3677c
BLAKE2b-256 7b3da324220aeb460068b747ba982d380db4d1fe67dfa0d472ee852fe83534ac

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 777fbebbbe75c3230376bc7bb3db52dedcf49e8a7cf21baa5fe35f2088d9e9af
MD5 d8f7f593eb6611165e226ba70b3ad772
BLAKE2b-256 23b48670f0a8923b61594008ce85f88facf8509a5d37068a49c6b6085bbfbe29

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 17fb898c83409d07606589ca9db9039d330d7692dc27774d1bc304c7c9588a53
MD5 9d7155917328d778cb8716bb038fbc0c
BLAKE2b-256 a1bd7ea8c73f890deaf6470434122f1e38285f2bf9f58c6978a0f97a852aa4db

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 035f2604dc64387961a01e7292faeeaadd14420bb165c67630c4c39470eb5cf9
MD5 c153a48f23c43c4249b3b92573015c58
BLAKE2b-256 1d676ea9c61fb092a05a215ff217258b9db0984939b6f6ca2a74d68b7b6e9baa

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3843d1ac1d900f6f93fee0d5718d83bbf580efe155678873cce55dd8768583f2
MD5 c905909320257ed97d80868ce6ece618
BLAKE2b-256 7e53c0911320a5e9cf707bfbbe71a5801f272127d5d3685fae1d534f01171213

See more details on using hashes here.

File details

Details for the file toposolve-0.1.17-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.17-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 23c3afd06afe3fd7c8fe5c55a415335474d319f1afb02ba3414ff092ad056aea
MD5 1423bdaf6cc42f635fbd603afcbb1030
BLAKE2b-256 574dd07f77f86315db47f1d69dcfe68b001cfa7bc094f0f2c95a7730723c3454

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page