Algorithms for performing joint inference of labels in a network