Package edu.cmu.tetrad.graph
Class GraphTransforms
java.lang.Object
edu.cmu.tetrad.graph.GraphTransforms
Transformations that transform one graph into another.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Method Summary
Modifier and TypeMethodDescriptionstatic Graph
dagFromCpdag
(Graph graph) dagFromCpdag.static Graph
dagFromCpdag
(Graph cpdag, Knowledge knowledge) Returns a random DAG from the given CPDAG.static Graph
dagToCpdag
(Graph dag) Returns the completed partially directed acyclic graph (CPDAG) for a given directed acyclic graph (DAG).static @NotNull Graph
Converts a Directed Acyclic Graph (DAG) to a Partial Ancestral Graph (PAG) using the DagToPag algorithm.generateCpdagDags
(Graph cpdag, boolean orientBidirectedEdges) Generates the list of DAGs in the given cpdag.getAllGraphsByDirectingUndirectedEdges
(Graph skeleton) Returns a list of all possible graphs obtained by directing undirected edges in the given 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
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.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.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
zhangMagFromPag
(Graph pag) Transforms a partially ancestral graph (PAG) into a maximally ancestral graph (MAG) using Zhang's 2008 Theorem 2.
-
Method Details
-
dagFromCpdag
dagFromCpdag.
-
dagFromCpdag
Returns a random DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.- Parameters:
cpdag
- the CPDAGknowledge
- the knowledge- Returns:
- a DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
-
transformCpdagIntoRandomDag
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
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
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
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
Generates the list of DAGs in the given cpdag. -
getDagsInCpdagMeek
Retrieves a list of directed acyclic graphs (DAGs) within the given completed partially directed acyclic graph (CPDAG) using the Meek rules. -
getAllGraphsByDirectingUndirectedEdges
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
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
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.
-