Home / Computer science / Traveling salesman problem (TSP) / Computation in Python / Implement
traveling_salesman.read_instance
def read_instance(file_name):
# Count the cities.
count = None
with open(file_name) as file:
count = int(file.readline())
# Load the city identifiers and coordinates.
instance = np.loadtxt(
file_name, dtype=int, comments=None, skiprows=1, max_rows=count
)
# TODO Validate the result.
return instance
None