Returns a copy of JunctionTree.

        Returns
        -------
        JunctionTree : copy of JunctionTree

        Examples
        --------
        >>> import numpy as np
        >>> from pgmpy.factors.discrete import DiscreteFactor
        >>> from pgmpy.models import JunctionTree
        >>> G = JunctionTree()
        >>> G.add_edges_from([(('a', 'b', 'c'), ('a', 'b')), (('a', 'b', 'c'), ('a', 'c'))])
        >>> phi1 = DiscreteFactor(['a', 'b'], [1, 2], np.random.rand(2))
        >>> phi2 = DiscreteFactor(['a', 'c'], [1, 2], np.random.rand(2))
        >>> G.add_factors(phi1,phi2)
        >>> modelCopy = G.copy()
        >>> modelCopy.edges()
        [(('a', 'b'), ('a', 'b', 'c')), (('a', 'c'), ('a', 'b', 'c'))]
        >>> G.factors
        [<DiscreteFactor representing phi(a:1, b:2) at 0xb720ee4c>,
         <DiscreteFactor representing phi(a:1, c:2) at 0xb4e1e06c>]
        >>> modelCopy.factors
        [<DiscreteFactor representing phi(a:1, b:2) at 0xb4bd11ec>,
         <DiscreteFactor representing phi(a:1, c:2) at 0xb4bd138c>]

def copy(self):
        """
        Returns a copy of JunctionTree.

        Returns
        -------
        JunctionTree : copy of JunctionTree

        Examples
        --------
        >>> import numpy as np
        >>> from pgmpy.factors.discrete import DiscreteFactor
        >>> from pgmpy.models import JunctionTree
        >>> G = JunctionTree()
        >>> G.add_edges_from([(('a', 'b', 'c'), ('a', 'b')), (('a', 'b', 'c'), ('a', 'c'))])
        >>> phi1 = DiscreteFactor(['a', 'b'], [1, 2], np.random.rand(2))
        >>> phi2 = DiscreteFactor(['a', 'c'], [1, 2], np.random.rand(2))
        >>> G.add_factors(phi1,phi2)
        >>> modelCopy = G.copy()
        >>> modelCopy.edges()
        [(('a', 'b'), ('a', 'b', 'c')), (('a', 'c'), ('a', 'b', 'c'))]
        >>> G.factors
        [<DiscreteFactor representing phi(a:1, b:2) at 0xb720ee4c>,
         <DiscreteFactor representing phi(a:1, c:2) at 0xb4e1e06c>]
        >>> modelCopy.factors
        [<DiscreteFactor representing phi(a:1, b:2) at 0xb4bd11ec>,
         <DiscreteFactor representing phi(a:1, c:2) at 0xb4bd138c>]

        """
        copy = JunctionTree(self.edges())
        copy.add_nodes_from(self.nodes())
        if self.factors:
            factors_copy = [factor.copy() for factor in self.factors]
            copy.add_factors(*factors_copy)
        return copy