Estimates a DAG from an Independencies()-object or a
        decision function for conditional independencies. This requires that
        the set of independencies admits a faithful representation (e.g. is a
        set of d-seperation for some BN or is closed under the semi-graphoid
        axioms). See `build_skeleton`, `skeleton_to_pdag`, `pdag_to_dag` for
        details.

        Parameters
        ----------
        nodes: list, array-like
            A list of node/variable names of the network skeleton.

        independencies: Independencies-instance or function.
            The source of independency information from which to build the skeleton.
            The provided Independencies should admit a faithful representation.
            Can either be provided as an Independencies()-instance or by passing a
            function `f(X, Y, Zs)` that returns `True` when X _|_ Y | Zs,
            otherwise `False`. (X, Y being individual nodes and Zs a list of nodes).

        Returns
        -------
        model: DAG instance

        Examples
        --------
        >>> from pgmpy.estimators import ConstraintBasedEstimator
        >>> from pgmpy.models import DAG
        >>> from pgmpy.independencies import Independencies

        >>> ind = Independencies(['B', 'C'], ['A', ['B', 'C'], 'D'])
        >>> ind = ind.closure()
        >>> skel = ConstraintBasedEstimator.estimate_from_independencies("ABCD", ind)
        >>> print(skel.edges())
        [('B', 'D'), ('A', 'D'), ('C', 'D')]

        >>> model = DAG([('A', 'C'), ('B', 'C'), ('B', 'D'), ('C', 'E')])
        >>> skel = ConstraintBasedEstimator.estimate_from_independencies(model.nodes(), model.get_independencies())
        >>> print(skel.edges())
        [('B', 'C'), ('A', 'C'), ('C', 'E'), ('D', 'B')]
        >>> # note that ('D', 'B') is flipped compared to the original network;
        >>> # Both networks belong to the same PDAG/are I-equivalent

def estimate_from_independencies(nodes, independencies):
        """Estimates a DAG from an Independencies()-object or a
        decision function for conditional independencies. This requires that
        the set of independencies admits a faithful representation (e.g. is a
        set of d-seperation for some BN or is closed under the semi-graphoid
        axioms). See `build_skeleton`, `skeleton_to_pdag`, `pdag_to_dag` for
        details.

        Parameters
        ----------
        nodes: list, array-like
            A list of node/variable names of the network skeleton.

        independencies: Independencies-instance or function.
            The source of independency information from which to build the skeleton.
            The provided Independencies should admit a faithful representation.
            Can either be provided as an Independencies()-instance or by passing a
            function `f(X, Y, Zs)` that returns `True` when X _|_ Y | Zs,
            otherwise `False`. (X, Y being individual nodes and Zs a list of nodes).

        Returns
        -------
        model: DAG instance

        Examples
        --------
        >>> from pgmpy.estimators import ConstraintBasedEstimator
        >>> from pgmpy.models import DAG
        >>> from pgmpy.independencies import Independencies

        >>> ind = Independencies(['B', 'C'], ['A', ['B', 'C'], 'D'])
        >>> ind = ind.closure()
        >>> skel = ConstraintBasedEstimator.estimate_from_independencies("ABCD", ind)
        >>> print(skel.edges())
        [('B', 'D'), ('A', 'D'), ('C', 'D')]

        >>> model = DAG([('A', 'C'), ('B', 'C'), ('B', 'D'), ('C', 'E')])
        >>> skel = ConstraintBasedEstimator.estimate_from_independencies(model.nodes(), model.get_independencies())
        >>> print(skel.edges())
        [('B', 'C'), ('A', 'C'), ('C', 'E'), ('D', 'B')]
        >>> # note that ('D', 'B') is flipped compared to the original network;
        >>> # Both networks belong to the same PDAG/are I-equivalent
        """

        skel, separating_sets = ConstraintBasedEstimator.build_skeleton(nodes, independencies)
        pdag = ConstraintBasedEstimator.skeleton_to_pdag(skel, separating_sets)
        dag = ConstraintBasedEstimator.pdag_to_dag(pdag)

        return dag