Welcome to TSP spanning tree’s documentation!


This is tsp_spanning module. Currently its contains tsp() function and wrappers which simplify usage on list of points

tsp_spanning.tsp(np.ndarray[np.float64_t, ndim=2] distances, int end=-1)

Function to calculate tsp path with spanning tree. Returned path always start with point with index 0.

  • distances (np.ndarray[np.float64_t, ndim=2]) – distances matrix
  • end – point in which tsp path should end. -1 means not use

list of point in order

Return type:



this function calculate distance matrix for given list of points then calculate tsp solution and return points in new order

Parameters:points – points to be visited
Returns:points in new order
Return type:np.ndarray

This function is replacement of scipy.spatial.distance.cdist if one do not need whole scipy module only for one function.

Parameters:points (np.ndarray) – points to calculate distance matrix.
Returns:distance matrix
Return type:np.ndarray

Indices and tables