AncestralGraph

Overview

class causaldag.classes.ancestral_graph.AncestralGraph(nodes: Set[T] = frozenset(), directed: Set[T] = frozenset(), bidirected: Set[T] = frozenset(), undirected: Set[T] = frozenset())[source]

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

Methods

AncestralGraph.copy() Return a copy of this ancestral graph.
AncestralGraph.to_amat() Convert the graph into an adjacency matrix.
AncestralGraph.from_amat(amat) Create a graph from an adjacency matrix.

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.

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.

Functions for 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.parents_of(nodes, Set[Hashable]]) Return the parents of the node or set of nodes nodes.
AncestralGraph.children_of(i, Set[Hashable]]) Return the children of the node or set of nodes i.
AncestralGraph.spouses_of(nodes, Set[Hashable]]) 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.