Class DagIterator

java.lang.Object
edu.cmu.tetrad.search.utils.DagIterator

public class DagIterator extends Object
Given a graph, lists all DAGs that result from directing the undirected edges in that graph every possible way. Uses a Meek-algorithm-type method.
Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    The given CPDAG must be a CPDAG.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DagIterator

      public DagIterator(Graph CPDAG)
      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.
      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 patterns, 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 pattern.