The method Tsp.create_random_instance()
creates a random instance of the TSP problem. Internally, it uses NetworkX's function random_geometric_graph()
.
To have your own graph, you can rely on NetworkX library as well to create it:
import networkx as nx
graph = nx.Graph()
graph.add_edges_from([[0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4]])
nx.draw(graph, with_labels = True)

Now, pass the graph to Tsp
constructor
tsp_instance = Tsp(graph)
Another method to create your own problem instance is by creating a TSPLIB file then use Tsp.parse_tsplib_format()
method.