当我运行我的代码时,我收到了这个 IndexError:
constraints[fr][to] = self.extra_constr[2]
IndexError: list index out of range
这是我的代码示例:
def determine_constr(self, parent_constr):
constraints = copy.deepcopy(parent_constr)
if self.extra_constr == None:
return constraints
fr = self.extra_constr[0]
to = self.extra_constr[1]
constraints[fr][to] = self.extra_constr[2]
constraints[to][fr] = self.extra_constr[2]
for i in range(2):
constraints = self.removeEdges(constraints)
constraints = self.addEdges(constraints)
return constraints