Commit 3fe39d20 authored by Roberts Ivanovs's avatar Roberts Ivanovs
Browse files

Added data integrity validation function.

This is to make sure that the distances.txt file does not contain any
mismatched data (as it currently does).
The user will be propmpted for input for each city that contains
false data.
parent 25eb54ae
......@@ -13,4 +13,20 @@ def generate_matrix(default=None):
path_len = [i for i in val[0].split("\t")]
matrix.append([int(i) for i in path_len[1:]])
for i in range(0, len(matrix)):
for j in range(0, len(matrix[i])):
if matrix[i][j] != matrix[j][i]:
if default is None:
f"Mismatched distances between {cities[i]}",
f"and {cities[j]}.",
f"\nCurrent values are: {matrix[i][j]} {matrix[j][i]}.",
"To continue, enter a new value:"
new_distance = input()
new_distance = default
matrix[i][j] = new_distance
matrix[j][i] = new_distance
return {"matrix": matrix, "cities": cities}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment