C++ code for MRF pairs and potencials