File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,29 @@ def readinp(filename: str) -> tsplib95.models.Problem:
34
34
Returns:
35
35
problem (tsplib95.models.Problem): The TSP problem object containing
36
36
nodes and distances.
37
+
38
+ Example:
39
+ >>> import tsplib95
40
+ >>> tsp_data = '''
41
+ ... NAME: sample
42
+ ... TYPE: TSP
43
+ ... DIMENSION: 4
44
+ ... EDGE_WEIGHT_TYPE: EUC_2D
45
+ ... NODE_COORD_SECTION
46
+ ... 1 0 0
47
+ ... 2 1 0
48
+ ... 3 0 1
49
+ ... 4 1 1
50
+ ... EOF
51
+ ... '''
52
+ >>> tsp_filename = "sample.tsp"
53
+ >>> with open(tsp_filename, "w") as f:
54
+ ... f.write(tsp_data)
55
+ >>> prob = readinp('sample.tsp')
56
+ >>> len(list(prob.get_nodes())) > 0
57
+ True
58
+ >>> isinstance(prob, tsplib95.models.StandardProblem)
59
+ True
37
60
"""
38
61
problem = tsplib95 .load (filename )
39
62
return problem
You can’t perform that action at this time.
0 commit comments