import numpy import opengm import matplotlib.pyplot as plt f1=numpy.ones([2]) f2=numpy.ones([2,2]) """ Grid: - 4x4=16 variables - second order factors in 4-neigbourhood all connected to the same function - higher order functions are shared """ size=3 gm=opengm.gm([2]*size*size) fid=gm.addFunction(f2) for y in range(size): for x in range(size): gm.addFactor(gm.addFunction(f1),x*size+y) if(x+1