图论,就像矩阵游戏一样,是编程和数据结构中的基本概念。数据库在存储和处理数据的方法中依赖数学对象进行逻辑连接。
def print_tree_by_level(tree):
for level in tree:
print(level)
def print_tree_by_level2(tree):
for level in tree:
for i in range(len(level)):
print(str(level[i]), end = ' ')
print()
def get_path(edge):
path = []
while edge.parent:
path.append(edge.tag)
edge = edge.parent
path.append(edge.tag)
return path[::-1]

将数学方法分成函数来封装并在循环中快速调用它们:
tree = generate_random_game_tree(g_cur_game)
solution = reverse_induction(tree, g_cur_game)
path = get_path(solution.path_last)
print("Game cost array: {}".format(solution.cost_array))
print("Winner is {} player ({})".format(1 + get_max_index(solution.cost_array), max(solution.cost_array)))
print("Path is {}".format(path))
我们还逐层循环打印输出。顶点必须按恒定长度对齐。如果没有用户可以理解的输出格式,就不可能测试自己。
以上就是图表作为蕴涵方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号