Python 3.x 以dict of dicts的形式读取多有向图忽略了多图输入

Python 3.x 以dict of dicts的形式读取多有向图忽略了多图输入,python-3.x,networkx,Python 3.x,Networkx,在NetworkX 2.5中,我似乎无法使用一个dict of dict读取多重图。下面是一个尝试往返某些数据的示例: G = nx.MultiDiGraph() G.add_edge(2, 3, weight=5) G.add_edge(2, 3, weight=4) # Create 2 edges dict_of_dicts = nx.to_dict_of_dicts(G) G2 = nx.MultiDiGraph(dict_of_dicts, multigraph_input=Tru

在NetworkX 2.5中,我似乎无法使用一个dict of dict读取多重图。下面是一个尝试往返某些数据的示例:

G = nx.MultiDiGraph()
G.add_edge(2, 3, weight=5)
G.add_edge(2, 3, weight=4)  # Create 2 edges

dict_of_dicts = nx.to_dict_of_dicts(G)
G2 = nx.MultiDiGraph(dict_of_dicts, multigraph_input=True)

print("Original", G.edges(data=True))
print("Round tripped", G2.edges(data=True))
print(G2.number_of_edges(), "edge(s) in round tripped graph")
在往返图G2中仅给出一条边:

Original [(2, 3, {'weight': 5}), (2, 3, {'weight': 4})]
Round tripped [(2, 3, {0: {'weight': 5}, 1: {'weight': 4}})]
1 edge(s) in round tripped graph
那么,作为一个dict of dict在一个多有向图中读取的格式是什么呢?

对于我来说,使用
create\u和
multigraph\u输入使用的参数是:

import networkx as nx

G = nx.MultiDiGraph()
G.add_edge(2, 3, weight=5)
G.add_edge(2, 3, weight=4)  # Create 2 edges

dict_of_dicts = nx.to_dict_of_dicts(G)
G2 = nx.from_dict_of_dicts(dict_of_dicts, create_using=nx.MultiDiGraph(), multigraph_input=True)

谢谢我也刚刚发现了这一点。奇怪的是,当直接实例化
nx.multi-digraph
时,它不起作用。您认为这是一个错误吗?如果您将数据传递给创建
multi-DiGraph
,它将被转发到
DiGraph
init,这可能会处理不同的部分(导致您观察到的差异)。您可以尝试在以下位置打开一个问题:并检查它们的。我不确定多重图的所有可能性是否都经过了那么多的测试。我刚刚在。谢谢