cascade.graph.marginalize

cascade.graph.marginalize(digraph, margin, max_steps)[source]

Marginalize a directed graph by keeping only a subset of observed nodes, optionally inferring indirect connections up to a maximal number of steps mediated by latent nodes.

Parameters:
  • digraph (DiGraph) – Directed graph

  • margin (Collection) – A list of marginal nodes

  • max_steps (int) – The maximal number of steps to infer indirect edges

Return type:

DiGraph

Returns:

Marginalized graph

Note

A new edge attribute “marginalize” is added that indicates whether the edge is direct or indirect.