docs: def to_markov_model(self):
          """
          Converts the factor graph into markov model.
  
          A markov model contains nodes as random variables and edge between
          two nodes imply interaction between them.
  
          Examples
          --------
          >>> from pgmpy.models import FactorGraph
          >>> from pgmpy.factors.discrete import DiscreteFactor
          >>> G = FactorGraph()
          >>> G.add_nodes_from(['a', 'b', 'c'])
          >>> phi1 = DiscreteFactor(['a', 'b'], [2, 2], np.random.rand(4))
          >>> phi2 = DiscreteFactor(['b', 'c'], [2, 2], np.random.rand(4))
          >>> G.add_factors(phi1, phi2)
          >>> G.add_nodes_from([phi1, phi2])
          >>> G.add_edges_from([('a', phi1), ('b', phi1),
          ...                   ('b', phi2), ('c', phi2)])
          >>> mm = G.to_markov_model()
          """
          mm = MarkovModel()
  
          variable_nodes = self.get_variable_nodes()
  
          if len(set(self.nodes()) - set(variable_nodes)) != len(self.factors):
              raise ValueError('Factors not associated with all the factor nodes.')
  
          mm.add_nodes_from(variable_nodes)
          for factor in self.factors:
              scope = factor.scope()
              mm.add_edges_from(itertools.combinations(scope, 2))
              mm.add_factors(factor)
  
          return mm