Tsp¶
- class Tsp(graph)[fuente]¶
Bases:
GraphOptimizationApplication
Optimization application for the «traveling salesman problem» [1] based on a NetworkX graph.
Referencias
[1]: «Travelling salesman problem», https://en.wikipedia.org/wiki/Travelling_salesman_problem
- Parámetros:
graph (Graph | ndarray | List) – A graph representing a problem. It can be specified directly as a NetworkX graph, or as an array or list format suitable to build out a NetworkX graph.
Attributes
Getter of the graph
Methods
create_random_instance
(n[, low, high, seed])Create a random instance of the traveling salesman problem
draw
([result, pos])Draw a graph with the result.
interpret
(result)Interpret a result as a list of node indices
parse_tsplib_format
(filename)Read a graph in TSPLIB format from file and return a Tsp instance.
random_graph
(num_nodes, num_edges[, seed])- param num_nodes:
The number of nodes in a graph
sample_most_likely
(state_vector)Compute the most likely binary string from state vector.
Convert a traveling salesman problem instance into a
QuadraticProgram
tsp_value
(z, adj_matrix)Compute the TSP value of a solution.