Package edu.cmu.tetrad.util
Class PagCache
java.lang.Object
edu.cmu.tetrad.util.PagCache
A cache for storing PAGs so that the only need to be calculated once per DAG.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the Directed Acyclic Graph (DAG) corresponding to the given graph if it is a PAG that has previously been converted from a DAG.static PagCache
Returns the singleton instance of the PagCache.Returns the PAG (Partial Ancestral Graph) corresponding to the given DAG (Directed Acyclic Graph).Returns the PAG (Partial Ancestral Graph) corresponding to the given DAG (Directed Acyclic Graph).
-
Method Details
-
getInstance
Returns the singleton instance of the PagCache.- Returns:
- the singleton instance of PagCache.
-
getPag
Returns the PAG (Partial Ancestral Graph) corresponding to the given DAG (Directed Acyclic Graph). If the conversion has already been performed earlier, the cached result will be returned. Otherwise, the DAG will be converted to a PAG, cached, and then returned.- Parameters:
graph
- the input DAG to be transformed into a PAG- Returns:
- the corresponding PAG of the input DAG
- Throws:
IllegalArgumentException
- if the input graph is not a DAG
-
getPag
Returns the PAG (Partial Ancestral Graph) corresponding to the given DAG (Directed Acyclic Graph). If the conversion has already been performed earlier, the cached result will be returned. Otherwise, the DAG will be converted to a PAG, cached, and then returned.- Parameters:
graph
- the input DAG to be transformed into a PAGknowledge
- the knowledge that should be used for the conversionverbose
- whether to print verbose output- Returns:
- the corresponding PAG of the input DAG
- Throws:
IllegalArgumentException
- if the input graph is not a DAG
-
getDag
Returns the Directed Acyclic Graph (DAG) corresponding to the given graph if it is a PAG that has previously been converted from a DAG. Otherwise, if it is a DAG, the input graph is returned as is. Otherwise, null is returned.- Parameters:
graph
- the input graph to be checked and potentially converted to a DAG- Returns:
- the corresponding DAG if the input graph is a legal DAG or present in cache; null otherwise
-