長いプログラムのコードチャンクのこの部分で問題が発生しています
print GInfo[i].DualVariables, "\n", GInfo[i].Components
for i in GInfo[i].Components:
print i, tuple(i)
if (tuple(i) not in GInfo[i].DualVariables):
------ Do Something ---------
ここで、GInfoはクラスGraphInfoのオブジェクトです。
class GraphInfo:
def __init__(self):
self.G = nx.Graph()
self.Components = []
self.ActiveStatus = {}
self.ContainsCommon = {}
self.p = {}
self.Edges = []
self.DualVariables = {}
self.Bound = {}
ご覧のとおり、DualVariablesはdictであり、Componentsはリストです。コードのサンプルインスタンスの出力は次のとおりです。
{(0,): 0.0, (1,): 31.5, (2,): 31.5, (8,): 31.5, (3,): 31.5, (4,): 31.5, (5,): 31.5,(6,): 31.5, (7,): 31.5}
[[8, 7], [0], [1], [2], [3], [4], [5], [6]]
[8, 7] (8, 7)
エラーが続く
TypeError: list indices must be integers, not list
if条件が存在する行。
この問題についての助けをいただければ幸いです。