factors = [factor for factor in working_factors[var]
if not set(factor.variables).intersection(eliminated_variables)]
phi = factor_product(*factors)
phi.reduce("{variable}_0".format(variable=var))
cliques.add(tuple(phi.scope()))
del working_factors[var]
for variable in phi.variables:
After Change
for var in elimination_order:
factors = [factor for factor in working_factors[var]
if not set(factor).intersection(eliminated_variables)]
phi = set(itertools.chain(*factors)).difference({var})
cliques.add(tuple(phi))
del working_factors[var]
for variable in phi:
working_factors[variable].append(list(phi))