This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This package(Christofides) provides a way to implement Christofides algorithm for solving Travelling Saleman Problem(TSP) to obtain an approximate solution on an undirected graph(Distance Matrix) provided as an upper Triangular matrix. The Distance from a node on to itself is assumed 0.

Usage

Use the compute() function which takes as input a distance_matrix and returns a Christofides solution as follows:

from python-christofides import christofides
TSP = christofides.compute(distance_matrix)

The Distance Matrix is an upper Triangular matrix with distance from a node on to itself 0, since Christofides algorithm could only be applied for undirected graphs. Also the distance between a node on to itself is practically 0. Example for distance_matrix is as follows, distance_matrix =

[[0,45,65,15],
 [0,0,56,12],
 [0,0,0,89],
 [0,0,0,0]]

The above distance_matrix should be provided as an input to christofides.compute(), when we want to calculate TSP for distance =

[[0,45,65,15],
[45,0,56,12],
[65,56,0,89],
[15,12,89,0]]
christofides.compute(distance_matrix) returns a Dictionary with following Keys:
Christofides_Solution, Travel_Cost, MST, Odd_Vertices Indexes, Multigraph, Euler_Tour
  • Christofides_Solution: A list consisting of approximate tour for TSP.

    Use: TSP[‘Chistofides_Solution’]

  • Travel_Cost: The cost of TSP tour generated.

    Use: TSP[‘Travel_Cost’]

  • MST: The minimum spanning tree generated during the Christofides algorithm.

    Use: TSP[‘MST’]

  • Odd_Vertices: A list of odd vertices of minimum spanning tree.

    Use: TSP[‘Odd_Vertices’]

  • Indexes: List of edges from minimum cost perfect matching of odd vertices.

    Use: TSP[‘Indexes’]

  • Multigraph: Edges of multigraph formed after Indexing.

    Use: TSP[‘Multigraph’]

  • Euler_Tour: The Euler Tour of the Multigraph.

    Use: TSP[‘Euler_Tour’]

Support Functions in christofides

  • _csr_gen_triples(csr_matrix)
  • _odd_vertices_of_MST(distance_matrix, number_of_nodes)
  • min_Munkres(distance_matrix, bipartitie_graphs)
  • Munkres_cost(indexes, bipartite_graph)
  • bipartite_Graph(distance_matrix, bipartite_set, odd_vertices)
  • create_Multigraph(distance_matrix, MST, indexes, odd_vertices)
  • Euler_Tour(multigraph)
  • shortcut_Euler_Tour(tour)
  • cost(christofides_tour, distance_matrix)

Install

Download the Package and use:

python setup.py install

or:

pip install python-christofides

Additional Packages

scipy, numpy, networkx, munkres

Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
python-christofides-0.1.1.tar.gz (5.6 kB) Copy SHA256 Checksum SHA256 Source Jan 8, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting