antecedent.graph

Graph interchange and typed graph stubs.

 1"""Graph types and interchange helpers.
 2
 3Prefer class methods (``Dag.from_dot``, ``Dag.to_json``, …). Free
 4``dag_from_*`` / ``dag_to_*`` functions remain thin aliases that return
 5``(node_count, edges[, names])`` for low-level codecs.
 6"""
 7
 8from __future__ import annotations
 9
10from ._native import (
11    Admg,
12    Cpdag,
13    Dag,
14    Pag,
15    TemporalCpdag,
16    TemporalDag,
17    TemporalPag,
18    dag_from_dot,
19    dag_from_gml,
20    dag_from_json,
21    dag_from_networkx_adjacency,
22    dag_from_networkx_node_link,
23    dag_to_dot,
24    dag_to_gml,
25    dag_to_json,
26    dag_to_networkx_adjacency,
27    dag_to_networkx_node_link,
28)
29
30__all__ = [
31    "Admg",
32    "Cpdag",
33    "Dag",
34    "Pag",
35    "TemporalCpdag",
36    "TemporalDag",
37    "TemporalPag",
38    "dag_from_dot",
39    "dag_from_gml",
40    "dag_from_json",
41    "dag_from_networkx_adjacency",
42    "dag_from_networkx_node_link",
43    "dag_to_dot",
44    "dag_to_gml",
45    "dag_to_json",
46    "dag_to_networkx_adjacency",
47    "dag_to_networkx_node_link",
48]
class Admg:

Named ADMG (directed + bidirected).

def from_edges(cls, /, names, directed, bidirected=None):
def nodes(self, /):
def parents(self, /, name):
def children(self, /, name):
def bidirected_neighbors(self, /, name):
def node_count(self, /):
def from_dot(cls, /, dot):
def to_dot(self, /):
def from_json(cls, /, json):
def to_json(self, /):
def from_gml(cls, /, gml):
def to_gml(self, /):
def m_separated(self, /, x, y, z=None):

Whether x is m-separated from y given z.

class Cpdag:

Named static CPDAG.

def from_directed_undirected(cls, /, names, directed, undirected=None):
def from_edges(cls, /, names, edges):
def nodes(self, /):
def edges(self, /):
def parents(self, /, name):
def children(self, /, name):
def undirected_neighbors(self, /, name):
def try_into_dag(self, /):
def node_count(self, /):
def from_dot(cls, /, dot):
def to_dot(self, /):
def from_json(cls, /, json):
def to_json(self, /):
def from_gml(cls, /, gml):
def to_gml(self, /):
class Dag:

Named static DAG.

def from_edges(cls, /, names, edges):
def from_dot(cls, /, dot):
def nodes(self, /):
def edges(self, /):
def parents(self, /, name):
def children(self, /, name):
def node_count(self, /):
def to_dot(self, /):
def from_json(cls, /, json):
def to_json(self, /):
def from_gml(cls, /, gml):
def to_gml(self, /):
def from_networkx_adjacency(cls, /, json):
def to_networkx_adjacency(self, /):
def d_separated(self, /, x, y, z=None):

Whether x is d-separated from y given z.

def latent_project(self, /, observed):

Latent-project onto observed variable names; returns an Admg.

class Pag:

Named static PAG.

def from_marked_edges(cls, /, names, edges):
def nodes(self, /):
def neighbors(self, /, name):
def directed_children(self, /, name):
def node_count(self, /):
def from_dot(cls, /, dot):
def to_dot(self, /):
def from_json(cls, /, json):
def to_json(self, /):
def from_gml(cls, /, gml):
def to_gml(self, /):
def m_separated(self, /, x, y, z=None, *, max_paths=32, max_len=6):

Definite-status m-separation of x and y given z.

class TemporalCpdag:

Named temporal CPDAG over lagged variables.

def from_lagged_edges(cls, /, names, directed, undirected):
def try_into_temporal_dag(self, /):
def node_count(self, /):
class TemporalDag:

Named temporal DAG over lagged variables.

def from_lagged_edges(cls, /, names, edges):
def nodes(self, /):

Lagged nodes as (name, lag) pairs.

def edges(self, /):

Directed edges as (src, src_lag, tgt, tgt_lag).

def node_count(self, /):
class TemporalPag:

Named temporal PAG over lagged variables.

def from_marked_lagged_edges(cls, /, names, edges):
def node_count(self, /):
def dag_from_dot(dot):

Parse DOT digraph text; return (node_count, edges).

def dag_from_gml(gml):

Parse GML digraph text; return (node_count, edges).

def dag_from_json(json):

Parse JSON DAG document; return (node_count, edges, variable_names|None).

def dag_from_networkx_adjacency(json):

Parse NetworkX adjacency JSON; return (node_count, edges).

def dag_to_dot(node_count, edges):

Emit DOT for a numeric DAG given node_count and edges.

def dag_to_gml(node_count, edges):

Emit GML for a numeric DAG.

def dag_to_json(node_count, edges, variable_names):

Emit JSON for a numeric DAG.

def dag_to_networkx_adjacency(node_count, edges, variable_names):

Emit NetworkX adjacency JSON for a numeric DAG.