Partial Ancestral Graph (PAG)

a PAG
class pyagrum.PAG(*args)

PAG represents a Partial Ancestral Graph, the output of the FCI algorithm.

A PAG is a pyagrum.MarkedGraph representing 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:

Typically obtained via BNLearner.learnPAG() after calling useFCI(), or by pyagrum.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

saveGUM()

Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks).

saveGUMstring()

Save the graph as a jgum string (see pyagrum.graphFromGUMString to read it back).

toMixedGraph()

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

addEdge()

Add an edge between two nodes with specified endpoint marks.

addNode()

Add a new node to the graph and return its id.

addNodeWithId()

Add a node with a chosen id.

addNodes()

Add n new nodes to the graph.

adjacencyMatrix()

adjacency matrix from a graph/graphical models

children()

clear()

Remove all the nodes and edges from the graph.

clearEdges()

Remove all edges and their endpoint marks from the graph.

clearNodes()

Remove all the nodes, hence all the edges and their marks, from the graph (same as clear()).

connectedComponents()

connectedComponentsCount()

number of connected components

connectedComponentsList()

connected components as a dict of sets

edges()

empty()

Check whether the graph has no nodes.

emptyEdges()

Check whether the graph has no edges.

eraseEdge()

Erase the edge (and its marks) if it exists.

eraseNeighbours()

Remove all edges adjacent to a given node (and their marks).

eraseNode()

Erase the node and all the adjacent edges.

existsEdge()

Check whether an edge exists between two nodes.

existsNode()

Check whether a node with the given id exists in the graph.

hasName()

Check whether a node has an explicitly assigned name.

idFromName()

Return the id of the node with the given name, or None if no such name exists.

idsFromNames()

The ids of nodes given by their names, in a container of the same type.

isArrowhead()

Return True if the mark at dst (seen from src) is an arrowhead.

isBidirected()

Return True if both endpoints of edge (x, y) are arrowheads (bidirected edge).

isCircle()

Return True if the mark at dst (seen from src) is a circle.

isDefCollider()

Return True if z is a definite collider on the path x-z-y.

isDefinitelyDirected()

Return True if the edge x-y is definitely directed from x to y.

isTail()

Return True if the mark at dst (seen from src) is a tail.

isUndirected()

Return True if the edge x-y has a tail at both ends (x–y).

markAt()

Return the endpoint mark on the dst side of edge (src, dst).

nameFromId()

Return the name of a node, or its id as a string if no name was set.

namesFromIds()

The names of nodes given by their ids, in a container of the same type.

neighbours()

nodes()

parents()

reorientAllWith()

Set all endpoint marks in the graph to the given mark.

setMarkAt()

Set the endpoint mark on the dst side of edge (src, dst).

setName()

Assign a name to a node.

size()

Return the number of nodes in the graph.

sizeEdges()

Return the number of edges in the graph.

skeleton()

spouses()

toDot()

Return a Graphviz dot representation of the graph.

undirectedNeighbours()