class definition of factor graph