graphical_models.classes.mags.ancestral_graph.AncestralGraph.induced_subgraph

AncestralGraph.induced_subgraph(nodes: Set[Hashable])[source]

Return the induced subgraph over only nodes

Parameters

nodes – Set of nodes for the induced subgraph.

Returns

Induced subgraph over nodes.

Return type

AncestralGraph

Examples

>>> from graphical_models import AncestralGraph
>>> g = AncestralGraph(bidirected={(1, 2), (1, 4)}, directed={(1, 3), (2, 3)})
>>> g.induced_subgraph({1, 2, 3})
Directed edges: {(2, 3), (1, 3)}, Bidirected edges: {frozenset({1, 2})}, Undirected edges: set()