Professional Documents
Culture Documents
Ai PRA7
Ai PRA7
def main():
# Example data: cities and their distances (replace with your own data)
cities = ["A", "B", "C", "D"]
distances = [
[0, 10, 15, 20],
[10, 0, 35, 25],
[15, 35, 0, 30],
[20, 25, 30, 0]
]
print("\nOptimal Tour:")
for idx in min_path:
print(cities[idx], end=" -> ")
print(cities[min_path[0]]) # Return to the starting city to complete the cycle
if __name__ == "__main__":
main()
Output: