gpt4 book ai didi

python - 为什么在 Python 中使用字典表示图形?

转载 作者:太空狗 更新时间:2023-10-30 01:21:23 25 4
gpt4 key购买 nike

<分区>

Python 不直接支持图形,但很多消息来源说它们可以使用字典表示,例如。

graph = { "a" : ["c"],
"b" : ["c", "e"],
"c" : ["a", "b", "d", "e"],
"d" : ["c"],
"e" : ["c", "b"],
"f" : []
}

由于这是一个无向图,字典是有向映射,所以看起来确实不简洁。说 graph = {'x':['y'], 'y':['x']} 真的比说 graph = {{'x', ' y'}} ?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com