Последняя функция отображения пути не работает. Он генерирует возможный путь, но не направления. Может быть какая-то ошибка с отступом
def main():
print('Enter Start Node: ', end='')
source = input().strip()
print('Enter Goal Node: ', end='')
goal = input().strip()
if source not in GRAPH or goal not in GRAPH:
print("Error: City doesn't exist.")
else:
print('\nAll Possible Paths: ')
paths = dfs_paths(source, goal)
for path in paths:
print(' -> '.join(city for city in path))
print('\nCheapest Path: ')
cost, cheapest_path = ucs(source, goal)
print('Path Cost = ', cost)
print(' -> '.join(city for city in cheapest_path))
print('\nOptimal Path: ')
heuristic, cost, optimal_path = a_star(source, goal)
print('Heuristic = ', heuristic)
print('Path Cost = ', cost)
print(' -> '.join(city for city in optimal_path))
if __name__ == '__main__':
main()
Программа должна показать мне пути. Но это не так. Ниже приведен снимок экрана со ссылкой на выходы.