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 GraphcalcAdjacencyGraph(Graph dag) Calculates the adjacency graph for the given Directed Acyclic Graph (DAG).static GraphdagFromCpdag(Graph graph) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static GraphdagFromCpdag(Graph graph, boolean verbose) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static GraphdagFromCpdag(Graph graph, boolean meekPreventCycles, boolean verbose) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static GraphdagFromCpdag(Graph graph, Knowledge knowledge) dagFromCpdag.static GraphdagFromCpdag(Graph cpdag, Knowledge knowledge, boolean verbose) Returns a random DAG from the given CPDAG.static GraphdagToCpdag(Graph dag) Returns the completed partially directed acyclic graph (CPDAG) for a given directed acyclic graph (DAG).static @NotNull GraphConverts a Directed Acyclic Graph (DAG) to a Maximal Ancestral Graph (MAG) by adding arrows to the edges.static @NotNull GraphConverts 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 GraphConverts a maximal ancestral graph (MAG) into a partial ancestral graph (PAG).static GraphrevertToUnshieldedColliders(Graph graph, boolean circles) Reverts the provided graph to its unshielded colliders, with other endpoints oriented either as circles (PAG case) or tails (CPDAG case).static voidtransformCpdagIntoDag(Graph graph, Knowledge knowledge, boolean verbose) Transforms a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG) by orienting the undirected edges in the CPDAG.static GraphzhangMagFromPag(Graph pag) Transforms a partial ancestral graph (PAG) into a maximal ancestral graph (MAG) using Zhang's 2008 Theorem 2.
-
Method Details
-
dagFromCpdag
Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG). If the given CPDAG is not a PDAG (Partially Directed Acyclic Graph), returns null.- Parameters:
graph- the CPDAG to be converted into a DAG- Returns:
- a directed acyclic graph (DAG) obtained from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
-
dagFromCpdag
Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG). If the given CPDAG is not a PDAG (Partially Directed Acyclic Graph), returns null.- Parameters:
graph- the CPDAG to be converted into a DAGverbose- whether to print verbose output- Returns:
- a directed acyclic graph (DAG) obtained from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
-
dagFromCpdag
Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG). If the given CPDAG is not a PDAG (Partially Directed Acyclic Graph), returns null.- Parameters:
graph- the CPDAG to be converted into a DAGmeekPreventCycles- whether to prevent cycles using the Meek rules by orienting additional arbitrary unshielded colliders in the graphverbose- whether to print verbose output- Returns:
- a directed acyclic graph (DAG) obtained from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
-
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 knowledgeverbose- whether to print verbose output.- Returns:
- a DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.
-
transformCpdagIntoDag
Transforms a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG) by orienting the undirected edges in the CPDAG.- Parameters:
graph- The original graph from which the CPDAG was derived.knowledge- The knowledge available to check if a potential DAG violates any constraints.verbose- Whether to print verbose output.
-
zhangMagFromPag
Transforms a partial ancestral graph (PAG) into a maximal 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:
graph- The input DAG to be converted.- Returns:
- The resulting PAG obtained from the input DAG.
-
dagToMag
Converts a Directed Acyclic Graph (DAG) to a Maximal Ancestral Graph (MAG) by adding arrows to the edges.- Parameters:
dag- The input DAG to be converted.- Returns:
- The resulting MAG obtained from the input DAG.
-
calcAdjacencyGraph
Calculates the adjacency graph for the given Directed Acyclic Graph (DAG).- Parameters:
dag- The input MAG.- Returns:
- The adjacency graph represented by a Graph object.
-
revertToUnshieldedColliders
Reverts the provided graph to its unshielded colliders, with other endpoints oriented either as circles (PAG case) or tails (CPDAG case). The operation orients a copy of the graph with no orientations, then iterates through the unshielded colliders (X --> Y <-- Z with ~adj(X, Z)) in the original graph and makes these orientations in the new graph.- Parameters:
graph- the input graph on which the operation is performed.circles- if other endpoints should otherwise be circles (PAG case), false if tails (CPDAG case).- Returns:
- a new graph with the specified updates applied.
-
magToPag
Converts a maximal ancestral graph (MAG) into a partial ancestral graph (PAG).- Parameters:
mag- the maximal ancestral graph (MAG) to be converted- Returns:
- the resulting partial ancestral graph (PAG)
-