Data structures and algorithms for MRF partitioning.