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.16.tar.gz (5.5 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.16-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.16-cp312-cp312-macosx_11_0_arm64.whl (127.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

toposolve-0.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

toposolve-0.1.16-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.16-cp310-cp310-macosx_11_0_arm64.whl (125.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

toposolve-0.1.16-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.16-cp39-cp39-macosx_11_0_arm64.whl (125.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.9macOS 10.9+ x86-64

toposolve-0.1.16-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.16-cp38-cp38-macosx_11_0_arm64.whl (125.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

toposolve-0.1.16-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.16.tar.gz.

File metadata

  • Download URL: toposolve-0.1.16.tar.gz
  • Upload date:
  • Size: 5.5 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.16.tar.gz
Algorithm Hash digest
SHA256 a2118c7702d78167045c41e2daf3fa50ac5c2c77e5bcda45923b94160ba2aad8
MD5 d5571b185f37962eb904eab78ec446ff
BLAKE2b-256 5d6921b1577611fb0f584eecf3dc31e28f913b5ad99049173ca96e68ce4ff70e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e4fb27b4a57ed726b7c67c4c3fe0ddb5467d1216f5df6972c3a68d48c91d323
MD5 8d143fc6b010ec73e5eb43d10dcb5cf7
BLAKE2b-256 d22d603409a065df29d58729d60fe5b30e50c15da84f1040ea4297e776be047f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1903f34c257f46e87ac53e7e1449f02c0e6fe73b54a24d826613119486a4022
MD5 73900997fb63ee13b4b12d20c1e15767
BLAKE2b-256 635f22be2418837147a8ad62f874f0d5805a5f7f1af055a35741f2f844eb4c52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fdcd8927b41396c1f35af202e2129ef01795e166e174407b93b91fc5aaebe56a
MD5 f3320fec9ef14b9380dbd4a1aecc74f0
BLAKE2b-256 e5f2322c4aeacab24136aa961f34efc292e97925eef2d302043d885482d62367

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff33405eecce50c59af2b3702d6a6665c15b9b8dba28f82c7a974cbd48aba22c
MD5 198f41a99a44fd7f401bf0ef2c6cbf17
BLAKE2b-256 e8c9031798d9a88817d9dee7765bb0c5c4d646a21d31cbb9f1fee39784ba8511

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1b3e806b77fd410c53bc063e1b1362b53eb73a80cc49d08b661f6f1f36e9a8d
MD5 84f2e7c3a3a2f49d50b4a643832c3e8b
BLAKE2b-256 e912651b8f813ad48ad1c33307191b0e39f42f51ad3c1b802ac2e630ff038b1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c662e3bdc7cf931bc8e9d4808280f47badb942bb58ba2c34c1d0f9cbd279100
MD5 0db4e59dcca74d15ed934d15ee8fc2b7
BLAKE2b-256 7f2761b8234c9fcabcfc84306c3730a260254a95bdbc18bb35e1cec2369de9e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dce893d89a25a701ee1c0cc6f560213787e6fb62530219acc1ad0a5826705bc2
MD5 818feeafe2e6cdc4c94ba8d2c47cf66a
BLAKE2b-256 f13678b1e25306b0c2a7cc76a351de137ab21e659129e5311200b88a972e64e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39e3632fa1f575b645c8da724aa018d68673a2d5042d3de24eb0e497016464e4
MD5 cda438ee74282ce073347389e6745bd0
BLAKE2b-256 f7953386f01bc692087a1945f7bc335866a3a3194310bc2fd5cd117c602fea32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f8860039deae0111a1172164f033e12221ae072c060f1dcaea9668fcb106e69c
MD5 b1575196c91f60f551b87cae2045e5e4
BLAKE2b-256 ca956071da66f1446337466cb0b8b95de17889ce48e610369737e4f9078f389d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f8300ae316c101a1f0b23ff1ea60a2652a9a74b0ac8fa3e205f87211c2b3716
MD5 004fe0392ca419dca72fb63433123312
BLAKE2b-256 f8424740ba0cb0a9770e75d7407a84ceccd7a924947fd34f89b23bb9164d6116

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e182244fbf9ad295a997db335f81d2a01259130d1aaae9b069fed5c0a64f6e36
MD5 98e3fe05b28b2cf25f193d9f173a0bba
BLAKE2b-256 9fd660f3a3f9c3c13e6053dff37b43220b1e55c0595b31526452667328c1e244

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a54d50fb7c9f0ef0efebf3442fb3d838655dd0e16fd0886c7c3c0dfac22b4393
MD5 a297823bd38fe7a01dde537d0ecf9aa4
BLAKE2b-256 8666c1644706f5a2af415dcb388ff334274878437a63edbbeea962736a01df34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62eda0dade003c04c1872300e40538315cff79781617f8fc2ad187d83b244bf3
MD5 b016f50a1815267c7642f867250aa6c2
BLAKE2b-256 879db8dd230abbb27dd1a997be82e3f8281a40194b8fad0f68a1ab8357c63053

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7df98d6df6437f0b1d3d17edd72d8a76e163f0fb406023dd6f5641540481249a
MD5 2799afa97b2fe952911eefca581e4e1c
BLAKE2b-256 061c1e4205641376f5db434d26c0bc5aab589a2769b2c8d1f68aacd9208599e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toposolve-0.1.16-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0efdab0124cc0d944d51090c9fe3e80c108675c3f782538c48093a64e5a1d9aa
MD5 ea97cfed17b7b096fd919f4b8a385512
BLAKE2b-256 71bfa483f64f694e18940ad2a52d8346ad7aee383c6881e6e30cee0f0fbc60f2

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