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) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static Graph
dagFromCpdag
(Graph graph, boolean verbose) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static Graph
dagFromCpdag
(Graph graph, boolean meekPreventCycles, boolean verbose) Converts a completed partially directed acyclic graph (CPDAG) into a directed acyclic graph (DAG).static Graph
dagFromCpdag
(Graph graph, Knowledge knowledge) dagFromCpdag.static Graph
dagFromCpdag
(Graph cpdag, Knowledge knowledge, boolean meekPreventCycles, boolean verbose) 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 Maximal Ancestral Graph (MAG) by adding arrows to the edges.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, boolean meekPreventCycles, boolean verbose) 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 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
public static Graph dagFromCpdag(Graph cpdag, Knowledge knowledge, boolean meekPreventCycles, boolean verbose) Returns a random DAG from the given CPDAG. If the given CPDAG is not a PDAG, returns null.- Parameters:
cpdag
- the CPDAGknowledge
- the knowledgemeekPreventCycles
- whether to prevent cycles using the Meek rules by orienting additional arbitrary unshielded colliders in the graph.verbose
- whether to print verbose output.- 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, boolean meekPreventCycles, boolean verbose) 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.meekPreventCycles
- Whether to prevent cycles using the Meek rules by orienting additional arbitrary unshielded colliders in the graph.verbose
- Whether to print verbose output.
-
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
-
generateCpdagDags
-
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
-
dagToPag
-
dagToMag
-