Completed PDAG (CPDAG)
- class pyagrum.CPDAG(*args)
CPDAG represents a completed partially directed acyclic graph (or essential graph): the representation of a Markov equivalence class of DAGs.
Two DAGs are Markov equivalent iff they have the same skeleton and the same v-structures (Verma and Pearl 1990). The CPDAG of a class has an arc for each compelled arc (same orientation in all the DAGs of the class) and an undirected edge for each reversible one. It is a chain graph whose chain components are chordal (Andersson, Madigan and Perlman 1997).
A CPDAG cannot be modified (its properties are global): it is built from a DAG (
CPDAG.fromDAG(), Chickering 1995) or from a PDAG with a check (CPDAG.fromPDAG()).dSeparation()gives the d-separation of every DAG of the class (they are Markov equivalent); it is computed on a DAG of the class kept from the construction (consistentExtension()). It is also the c-separation of the chain graph of the CPDAG (a DAG and its essential graph are Markov equivalent, Andersson, Madigan and Perlman 1997, and the c-separation is complete, Studený and Bouckaert 1998).
Example
import pyagrum as gum
cpdag = gum.CPDAG.fromDAG(gum.fastDAG("A->B->C;D->C"))
sorted(cpdag.arcs()), sorted(cpdag.edges()) # B->C<-D compelled, A--B reversible
# ([(1, 2), (3, 2)], [(0, 1)])
Scientific notes
A CPDAG (completed partially directed acyclic graph, or essential graph) represents a Markov equivalence class of DAGs. Two DAGs are Markov equivalent iff they have the same skeleton and the same v-structures [1]. The CPDAG of a class has its skeleton, an arc for each compelled arc (with the same orientation in all the DAGs of the class) and an undirected edge for each reversible one [2].
Characterization [3] (Theorem 4.1). A graph is the CPDAG of a class of DAGs iff (i) it is a chain graph, (ii) its chain components are chordal, (iii) it has no induced \(a \to b - c\), and (iv) each of its arcs \(a \to b\) is strongly protected, i.e. occurs in one of these induced configurations: \(c \to a \to b\) with \(c\), \(b\) non adjacent; \(a \to b \leftarrow c\) with \(a\), \(c\) non adjacent; \(a \to c \to b\) together with \(a \to b\); \(a - c_1 \to b\) and \(a - c_2 \to b\) together with \(a \to b\), \(c_1\) and \(c_2\) non adjacent. Reversing the arc would create or destroy a v-structure in the first two cases, a directed cycle in the last two.
Construction. fromDAG (or pyagrum.graph.cpdag) runs the algorithm Find-Compelled of
[2] in linear time: the arcs are visited in the order of Order-Edges (heads by
increasing topological rank, then tails by decreasing rank) and labelled compelled or reversible. fromPDAG accepts
a PDAG iff it has a consistent extension whose CPDAG is the PDAG itself [4], and
contains(dag) checks that the CPDAG of the DAG is this one. A CPDAG is immutable: adding an arc to a CPDAG gives in
general a graph that is not a CPDAG.
Separation. dSeparation is the d-separation of any DAG of the class (they are Markov equivalent), computed on
a consistent extension kept from the construction. It is also the c-separation of the chain graph (see
pyagrum.ChainGraph): a DAG and its essential graph are Markov equivalent [3], the
c-separation is complete [5], and on a chain graph without induced \(a \to b - c\) the LWF and
AMP interpretations coincide [6] (Theorem 4.2).
Methods
adjacency matrix from a graph/graphical models |
|
The connected components of the graph (of its skeleton). |
|
number of connected components |
|
connected components as a dict of sets |
|
Check if the sets of nodes X and Y are d-separated (by the set of nodes Z if given) in every DAG represented by the CPDAG. |
|
The CPDAG of the Markov equivalence class of a DAG (algorithm Find-Compelled of Chickering 1995). |
|
Checked conversion of a PDAG into a CPDAG: the PDAG must be the CPDAG of its consistent extensions. |
|
Return the id of the node with the given name, or None if no such name exists. |
|
The ids of nodes given by their names, in a container of the same type. |
|
Return the name of a node, or its id as a string if no name was set. |
|
The names of nodes given by their ids, in a container of the same type. |
|
Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks). |
|
Save the graph as a jgum string (see |
|
The chain components (nodes linked by undirected edges) are drawn in clusters (color of the key |
|