Class GraphTransforms

java.lang.Object
edu.cmu.tetrad.graph.GraphTransforms

public class GraphTransforms extends Object
Transformations that transform one graph into another.
Version:
$Id: $Id
Author:
josephramsey
  • Method Summary

    Modifier and Type
    Method
    Description
    static Graph
    dagFromCpdag.
    static Graph
    dagFromCpdag(Graph cpdag, Knowledge knowledge)
    Returns a random DAG from the given CPDAG.
    static Graph
    Returns the completed partially directed acyclic graph (CPDAG) for a given directed acyclic graph (DAG).
    static @NotNull Graph
    dagToPag(Graph trueGraph)
    Converts a Directed Acyclic Graph (DAG) to a Partial Ancestral Graph (PAG) using the DagToPag algorithm.
    static List<Graph>
    generateCpdagDags(Graph cpdag, boolean orientBidirectedEdges)
    Generates the list of DAGs in the given cpdag.
    static List<Graph>
    Returns a list of all possible graphs obtained by directing undirected edges in the given graph.
    static List<Graph>
    getDagsInCpdagMeek(Graph cpdag, Knowledge knowledge)
    Retrieves a list of directed acyclic graphs (DAGs) within the given completed partially directed acyclic graph (CPDAG) using the Meek rules.
    static Graph
    Picks a random Maximal Ancestral Graph (MAG) from the given Partial Ancestral Graph (PAG) by randomly orienting the circle endpoints as either tail or arrow and then applying the final FCI orient algorithm after each change.
    static void
    Transforms a completed partially directed acyclic graph (CPDAG) into a random directed acyclic graph (DAG) by randomly orienting the undirected edges in the CPDAG in shuffled order.
    static void
    Transforms a partially ancestral graph (PAG) into a maximally ancestral graph (MAG) by randomly orienting the circle endpoints as either tail or arrow and then applying the final FCI orient algorithm after each change.
    static Graph
    Transforms a partially ancestral graph (PAG) into a maximally ancestral graph (MAG) using Zhang's 2008 Theorem 2.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • dagFromCpdag

      public static Graph dagFromCpdag(Graph graph)

      dagFromCpdag.

      Parameters:
      graph - a Graph object
      Returns:
      a Graph object
    • dagFromCpdag

      public static Graph dagFromCpdag(Graph cpdag, Knowledge knowledge)
      Returns a random DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
      Parameters:
      cpdag - the CPDAG
      knowledge - the knowledge
      Returns:
      a DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
    • transformCpdagIntoRandomDag

      public static void transformCpdagIntoRandomDag(Graph graph, Knowledge knowledge)
      Transforms a completed partially directed acyclic graph (CPDAG) into a random directed acyclic graph (DAG) by randomly orienting the undirected edges in the CPDAG in shuffled order.
      Parameters:
      graph - The original graph from which the CPDAG was derived.
      knowledge - The knowledge available to check if a potential DAG violates any constraints.
    • magFromPag

      public static Graph magFromPag(Graph pag)
      Picks a random Maximal Ancestral Graph (MAG) from the given Partial Ancestral Graph (PAG) by randomly orienting the circle endpoints as either tail or arrow and then applying the final FCI orient algorithm after each change. The PAG graph type is not checked.
      Parameters:
      pag - The partially ancestral pag to transform.
      Returns:
      The maximally ancestral pag obtained from the PAG.
    • transormPagIntoRandomMag

      public static void transormPagIntoRandomMag(Graph pag)
      Transforms a partially ancestral graph (PAG) into a maximally ancestral graph (MAG) by randomly orienting the circle endpoints as either tail or arrow and then applying the final FCI orient algorithm after each change.
      Parameters:
      pag - The partially ancestral graph to transform.
    • zhangMagFromPag

      public static Graph zhangMagFromPag(Graph pag)
      Transforms a partially ancestral graph (PAG) into a maximally ancestral graph (MAG) using Zhang's 2008 Theorem 2.
      Parameters:
      pag - The partially ancestral graph to transform.
      Returns:
      The maximally ancestral graph obtained from the PAG.
    • generateCpdagDags

      public static List<Graph> generateCpdagDags(Graph cpdag, boolean orientBidirectedEdges)
      Generates the list of DAGs in the given cpdag.
      Parameters:
      cpdag - a Graph object
      orientBidirectedEdges - a boolean
      Returns:
      a List object
    • getDagsInCpdagMeek

      public static List<Graph> getDagsInCpdagMeek(Graph cpdag, Knowledge knowledge)
      Retrieves a list of directed acyclic graphs (DAGs) within the given completed partially directed acyclic graph (CPDAG) using the Meek rules.
      Parameters:
      cpdag - The completed partially directed acyclic graph (CPDAG) from which to retrieve the DAGs.
      knowledge - The knowledge available to check if a potential DAG violates any constraints.
      Returns:
      A List of Graph objects representing the DAGs within the CPDAG.
    • getAllGraphsByDirectingUndirectedEdges

      public static List<Graph> getAllGraphsByDirectingUndirectedEdges(Graph skeleton)
      Returns a list of all possible graphs obtained by directing undirected edges in the given graph.
      Parameters:
      skeleton - the graph to transform
      Returns:
      a list of all possible graphs obtained by directing undirected edges
    • dagToCpdag

      public static Graph dagToCpdag(Graph dag)
      Returns the completed partially directed acyclic graph (CPDAG) for a given directed acyclic graph (DAG).
      Parameters:
      dag - The input DAG.
      Returns:
      The CPDAG resulting from applying Meek Rules to the input DAG.
    • dagToPag

      @NotNull public static @NotNull Graph dagToPag(Graph trueGraph)
      Converts a Directed Acyclic Graph (DAG) to a Partial Ancestral Graph (PAG) using the DagToPag algorithm.
      Parameters:
      trueGraph - The input DAG to be converted.
      Returns:
      The resulting PAG obtained from the input DAG.