Marked Graph
- class pyagrum.EdgeMark(value)
The mark at an end of an edge of a marked graph (
pyagrum.MarkedGraph,pyagrum.PAG).An edge x-y carries one mark at x and one at y:
x->yhas a tail at x and an arrowhead at y,x<->yan arrowhead at both ends,x--ya tail at both ends; a circle is an end whose mark is not determined (in a PAG, it varies across the equivalence class).
Attributes
The mark at an end of an edge of a marked graph ( |
|
The mark at an end of an edge of a marked graph ( |
|
The mark at an end of an edge of a marked graph ( |
- class pyagrum.MarkedGraph(*args)
MarkedGraph represents a graph whose edges carry a mark at each of their ends.
Each edge between nodes x and y has two marks, one at each end (
pyagrum.EdgeMark):EdgeMark.Circle(o): undetermined endEdgeMark.Tail(-): tailEdgeMark.Arrowhead(>): arrowhead
There is at most one edge between two nodes:
x->y(tail at x, arrowhead at y),x<->y,x--y,x o-> y,x o-o y… A marked graph is not an undirected graph: its skeleton is given byskeleton()and its directed view byparents,children,spousesandundirectedNeighbours.- MarkedGraph() -> MarkedGraph
default constructor
- MarkedGraph(src) -> MarkedGraph
- Parameters:
src (
pyagrum.MarkedGraph) – the marked graph to copy
See also
pyagrum.fastMarkedGraph,pyagrum.PAGandpyagrum.MAG.
Scientific notes
A marked graph has at most one edge between two nodes, with a mark at each end: a tail, an arrowhead or a circle. The
tails and arrowheads give the directed (\(\to\)), bidirected (\(\leftrightarrow\)) and undirected (\(-\))
edges of the ancestral graphs [1] (pyagrum.MAG); the circles are the marks that vary in
a Markov equivalence class of such graphs, in the partial ancestral graphs [2]
(pyagrum.PAG).
Conventions of pyAgrum: markAt(x, y) is the mark at the \(y\) end of the edge \(x - y\); an edge added
without marks is \(x \circ\!\!-\!\!\circ\, y\). The directed view is read from the marks: the parents of \(x\)
are the nodes \(y\) with \(y \to x\), its spouses the nodes with \(y \leftrightarrow x\), and a node
\(z\) is a definite collider on \(x - z - y\) when both edges have an arrowhead at \(z\). A marked graph
checks no other property.
Methods
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. |
|
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 |
|
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. |
|