Partial Ancestral Graph (PAG)
- class pyagrum.PAG(*args)
PAG represents a Partial Ancestral Graph, the output of the FCI algorithm.
A PAG is a
pyagrum.MarkedGraphrepresenting a Markov equivalence class of maximal ancestral graphs: an arrowhead or a tail is in all the graphs of the class, a circle varies across the class (Zhang 2008). No invariant is checked (the output of FCI on finite data may not be a valid PAG).- PAG() -> PAG
default constructor
- PAG(src) -> PAG
- Parameters:
src (
pyagrum.PAG) – the PAG to copy
Typically obtained via
BNLearner.learnPAG()after callinguseFCI(), or bypyagrum.fastPAG.
Scientific notes
A PAG (partial ancestral graph) represents a Markov equivalence class of maximal ancestral graphs (pyagrum.MAG): it
has their common skeleton, and a mark of the PAG is an arrowhead or a tail when this mark is in all the MAGs of the
class, a circle otherwise [1]. Its edges are thus \(\to\) (definitely directed),
\(\leftrightarrow\) (a latent confounder), \(-\) (selection bias), \(\circ\!\!\to\) (possibly directed),
\(\circ\!\!-\!\!\circ\) (completely uncertain) and \(-\!\!\circ\).
A PAG is the output of the FCI algorithm (pyagrum.BNLearner.learnPAG): the skeleton and the unshielded colliders come
from independence tests, then the orientation rules R1-R10 of [1] are applied; these rules are
complete, i.e. every circle left by them is a tail in some MAG of the class and an arrowhead in another one.
Conventions of pyAgrum: a PAG is a marked graph (pyagrum.MarkedGraph) whose invariants are not checked, since FCI on
finite data may give a graph that represents no class. A PAG has no separation of its own: the MAGs of its class are
Markov equivalent, so the m-separation of the representative MAG given by pyagrum.MAG (fromPAG) is the one of
all of them, when the PAG is valid.
Methods
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 |
|
Approximate conversion into a mixed graph: an edge with an arrowhead at one end only (-> or o->) becomes an arc, arrowhead-arrowhead two arcs, an edge without arrowhead an undirected edge. |
Methods inherited from MarkedGraph
Add an edge between two nodes with specified endpoint marks. |
|
Add a new node to the graph and return its id. |
|
Add a node with a chosen id. |
|
Add n new nodes to the graph. |
|
adjacency matrix from a graph/graphical models |
|
Remove all the nodes and edges from the graph. |
|
Remove all edges and their endpoint marks from the graph. |
|
Remove all the nodes, hence all the edges and their marks, from the graph (same as |
|
number of connected components |
|
connected components as a dict of sets |
|
Check whether the graph has no nodes. |
|
Check whether the graph has no edges. |
|
Erase the edge (and its marks) if it exists. |
|
Remove all edges adjacent to a given node (and their marks). |
|
Erase the node and all the adjacent edges. |
|
Check whether an edge exists between two nodes. |
|
Check whether a node with the given id exists in the graph. |
|
Check whether a node has an explicitly assigned name. |
|
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 True if the mark at dst (seen from src) is an arrowhead. |
|
Return True if both endpoints of edge (x, y) are arrowheads (bidirected edge). |
|
Return True if the mark at dst (seen from src) is a circle. |
|
Return True if z is a definite collider on the path x-z-y. |
|
Return True if the edge x-y is definitely directed from x to y. |
|
Return True if the mark at dst (seen from src) is a tail. |
|
Return True if the edge x-y has a tail at both ends (x–y). |
|
Return the endpoint mark on the dst side of edge (src, dst). |
|
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. |
|
Set all endpoint marks in the graph to the given mark. |
|
Set the endpoint mark on the dst side of edge (src, dst). |
|
Assign a name to a node. |
|
Return the number of nodes in the graph. |
|
Return the number of edges in the graph. |
|
Return a Graphviz dot representation of the graph. |
|