Updates (Ginta)

This commit is contained in:
Jonas_Jones 2023-12-22 16:25:48 +01:00
parent 27ac0f86c9
commit df295d1dfd
4 changed files with 284 additions and 8 deletions

View file

@ -1,5 +1,5 @@
'''EPR Übung 7'''
__author__ = "7987847, Werner"
__author__ = "7987847, Werner, 8004356, Gill"
import random
@ -141,10 +141,19 @@ if __name__ == "__main__":
try:
dimension = int(dimension)
except ValueError:
# Check if the dimension is positive
if dimension <= 0:
raise ValueError("Dimension must be a positive number.")
except (ValueError, TypeError) as e:
print("Bitte geben Sie eine positive Zahl ein.")
exit()
#Test 1 - Positive Number [3] as input --> generates Matrix successfully
#Test 2 - Negative Number [-1] as input --> Value Error
#Test 3 - String (Hello) as input --> Value Error
gened_matrix = gen_matrix(dimension)
print("Matrix:")
@ -153,7 +162,8 @@ if __name__ == "__main__":
optimal_path, optimal_cost= greedy_approach(gened_matrix)
print("\nGreedy Ansatz")
print("------------------")
print("Weg:", optimal_path)
print("Kosten:", optimal_cost)