* pairwise factor graph implementation