Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 NetworkX MultiDiGraph 中迭代边缘,如下所示:
for u, v, k, d in g.edges(keys=True, data=True): ...
在某些情况下,我在字典中找到id和键,但我无法弄清楚这些是何时或为什么被创建的,除非它只发生在.keydu==v
id
key
d
u==v
我一直无法找到导致这种情况的最小示例。我觉得很奇怪,钥匙k会在 attr dict 中重复d。
k
认为这已经解决了,我曾经用nx.readwrite.json_graph.adjacency_graph()JSON 读取/写入我的图表。我认为正是这一步将id和key值添加到边缘 attr_dict。
nx.readwrite.json_graph.adjacency_graph()
但是,我不知道这是否是从 JSON 读取时的错误,或者这是否按预期工作。