AncestralGraph

Overview

class graphical_models.classes.mags.ancestral_graph.AncestralGraph(nodes: Set = frozenset({}), directed: Set = frozenset({}), bidirected: Set = frozenset({}), undirected: Set = frozenset({}))[source]

Base class for ancestral graphs, used to represent causal models with latent variables.

Copying

AncestralGraph.copy()

Return a copy of this ancestral graph.

AncestralGraph.induced_subgraph(nodes)

Return the induced subgraph over only nodes

Information about nodes

AncestralGraph.parents_of(nodes)

Return the parents of the node or set of nodes nodes.

AncestralGraph.children_of(i)

Return the children of the node or set of nodes i.

AncestralGraph.spouses_of(nodes)

Return the spouses of the node or set of nodes nodes.

AncestralGraph.neighbors_of(nodes)

Return the neighbors of the node or set of nodes nodes.

AncestralGraph.descendants_of(nodes[, ...])

Return the descendants of the node or set of nodes nodes.

AncestralGraph.ancestors_of(nodes[, ...])

Return the ancestors of the node or set of nodes nodes.

AncestralGraph.district_of(node[, node_subset])

Return the district of a node, i.e., the set of nodes reachable by bidirected edges.

AncestralGraph.markov_blanket_of(node[, flat])

Return the Markov blanket of a node with respect to the whole graph.

Graph modification

AncestralGraph.add_node(node)

Add a node to the ancestral graph.

AncestralGraph.remove_node(node[, ignore_error])

Remove node.

AncestralGraph.add_directed(i, j)

Add a directed edge from node i to node j.

AncestralGraph.remove_directed(i, j[, ...])

Remove the directed edge from i to j.

AncestralGraph.add_bidirected(i, j)

Add a bidirected edge between nodes i and j.

AncestralGraph.remove_bidirected(i, j[, ...])

Remove the bidirected edge between i and j.

AncestralGraph.add_undirected(i, j)

Add an undirected edge between nodes i and j.

AncestralGraph.remove_undirected(i, j[, ...])

Remove the undirected edge between i and j.

AncestralGraph.add_nodes_from(nodes)

Add nodes to the ancestral graph.

AncestralGraph.remove_edge(i, j[, ignore_error])

Remove the edge between i and j, regardless of edge type.

AncestralGraph.remove_edges(edges[, ...])

Remove all edges in edges from the graph, regardless of edge type.

Graph properties

AncestralGraph.legitimate_mark_changes([...])

Return directed edges that can be changed to bidirected edges, and bidirected edges that can be changed to directed edges.

AncestralGraph.discriminating_triples([verbose])

Return the discriminating triples of the graph, which are triples of nodes that determine the discriminating paths.

AncestralGraph.discriminating_paths([verbose])

TODO

AncestralGraph.is_maximal([new, verbose])

TODO

AncestralGraph.c_components()

Return the c-components of this graph.

AncestralGraph.colliders()

TODO

AncestralGraph.vstructures()

TODO

AncestralGraph.has_directed(i, j)

Check if this graph has the directed edge i->``j``.

AncestralGraph.has_bidirected(i, j)

Check if this graph has a bidirected edge between i and j.

AncestralGraph.has_undirected(i, j)

Check if this graph has an undirected edge between i and j.

AncestralGraph.has_any_edge(i, j)

Check if i and j are adjacent in this graph.

Ordering

AncestralGraph.topological_sort()

Return a linear order that is consistent with the partial order implied by ancestral relations of this graph.

Comparison to other AncestralGraphs

AncestralGraph.shd_skeleton(other)

Compute the structure Hamming distance between the skeleton of this graph and the skeleton of another graph.

AncestralGraph.markov_equivalent(other)

Check if this graph is Markov equivalent to the graph other.

AncestralGraph.is_imap(other[, certify])

Check if this graph is an IMAP of the graph other, i.e., all m-separation statements in this graph are also m-separation statements in other.

AncestralGraph.is_minimal_imap(other[, ...])

TODO

Separation Statements

AncestralGraph.msep(A, B[, C])

Check whether A and B are m-separated given C, using the Bayes ball algorithm.

AncestralGraph.msep_from_given(A[, C])

Find all nodes m-separated from A given C.

Conversion to/from other formats

AncestralGraph.to_amat()

Convert the graph into an adjacency matrix.

AncestralGraph.from_amat(amat)

Create a graph from an adjacency matrix.