Class DagInCPDAGIterator

java.lang.Object
edu.cmu.tetrad.search.DagInCPDAGIterator

public class DagInCPDAGIterator extends Object
Given a pattern, lists all of the DAGs in that pattern. In the form of an iterator--call hasNext() to see if there's another one and next() to get it. next() will return null if there are no more.
Author:
Joseph Ramsey
  • Constructor Details

    • DagInCPDAGIterator

      public DagInCPDAGIterator(Graph CPDAG)
    • DagInCPDAGIterator

      public DagInCPDAGIterator(Graph CPDAG, Knowledge knowledge)
    • DagInCPDAGIterator

      public DagInCPDAGIterator(Graph CPDAG, Knowledge knowledge, boolean allowArbitraryOrientations, boolean allowNewColliders)
      The given CPDAG must be a CPDAG. If it does not consist entirely of directed and undirected edges and if it is not acyclic, it is rejected.
      Parameters:
      CPDAG - The CPDAG for which DAGS are wanted.
      allowArbitraryOrientations - True if arbitrary orientations are allowable when reasonable ones cannot be made. May result in cyclic outputs.
      Throws:
      IllegalArgumentException - if the CPDAG is not a CPDAG.
  • Method Details

    • next

      public Graph next()
      Successive calls to this method return successive DAGs in the CPDAG, in a more or less natural enumeration of them in which an arbitrary undirected edge is picked, oriented one way, Meek rules applied, then a remaining unoriented edge is picked, oriented one way, and so on, until a DAG is obtained, and then by backtracking the other orientation of each chosen edge is tried. Nonrecursive, obviously.

      Returns:
      a Graph instead of a DAG because sometimes, due to faulty CPDAGs, a cyclic graph is produced, and the end-user may need to decide what to do with it. The simplest thing is to construct a DAG (Dag(graph)) and catch an exception.
    • hasNext

      public boolean hasNext()
      Returns:
      true just in case there is still a DAG remaining in the enumeration of DAGs for this CPDAG.
    • getKnowledge

      public Knowledge getKnowledge()