【发布时间】:2014-08-08 14:17:15
【问题描述】:
获取有向图的所有边对的最佳方法是什么。我只需要那些具有相反方向的边缘。我需要它来比较关系的对称性。
我寻求以下结果(虽然我不确定获得结果的最佳形式) 输入:
[(a,b,{'weight':13}),
(b,a,{'weight':5}),
(b,c,{'weight':8}),
(c,b,{'weight':6}),
(c,d,{'weight':3}),
(c,e,{'weight':5})] #Last two should not appear in output because they do not have inverse edge.
输出:
[set(a,b):[13,5],
set(b,c):[8,6]]
这里的序列是重要的,因为它告诉了方向。
我应该调查什么?
【问题讨论】:
-
您的输入看起来无效 -
a、b等真的是变量吗?weight也是变量吗?
标签: python combinations permutation networkx