riantr/moonbit_dowhy/graph does not have a README file

    CausalGraph

    pub struct CausalGraph {
    treatment_name : Array[String]
    outcome_name : Array[String]
    graph : DirectedGraph
    observed : Map[String, Bool]
    effect_modifiers : Array[String]
    }

    A causal graph with the semantic role of every node.

    CausalGraph::add_missing_nodes_as_common_causes

    fn CausalGraph::add_missing_nodes_as_common_causes(self : CausalGraph, observed_node_names : Array[String]) -> DirectedGraph

    Add the columns of the data that are not part of the graph as confounders.

    CausalGraph::add_unobserved_common_cause

    fn CausalGraph::add_unobserved_common_cause(self : CausalGraph) -> DirectedGraph

    Add an unobserved common cause to the graph.

    CausalGraph::all_observed

    fn CausalGraph::all_observed(self : CausalGraph, node_names : Array[String]) -> Bool

    Whether every given node is observed.

    CausalGraph::check_dseparation

    fn CausalGraph::check_dseparation(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String], nodes3 : Array[String], new_graph : DirectedGraph?) -> Bool

    Whether the two node sets are d-separated given the conditioning set.

    CausalGraph::check_valid_backdoor_set

    fn CausalGraph::check_valid_backdoor_set(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String], nodes3 : Array[String], new_graph : DirectedGraph?) -> Bool

    Whether the candidate set blocks the backdoor paths.

    CausalGraph::check_valid_frontdoor_set

    fn CausalGraph::check_valid_frontdoor_set(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String], candidate_nodes : Array[String], frontdoor_paths : Array[Array[String]], new_graph : DirectedGraph?) -> Bool

    Whether the candidate set is a valid frontdoor set.

    CausalGraph::check_valid_mediation_set

    fn CausalGraph::check_valid_mediation_set(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String], candidate_nodes : Array[String], mediation_paths : Array[Array[String]]) -> Bool

    Whether the candidate set mediates the effect.

    CausalGraph::directed_graph

    fn CausalGraph::directed_graph(self : CausalGraph) -> DirectedGraph

    The underlying directed graph.

    CausalGraph::do_surgery

    fn CausalGraph::do_surgery(self : CausalGraph, node_names : Array[String], remove_outgoing_edges : Bool, remove_incoming_edges : Bool, target_node_names : Array[String], remove_only_direct_edges_to_target : Bool) -> DirectedGraph

    A graph with the edges of the given nodes removed.

    CausalGraph::get_adjacency_matrix

    The adjacency matrix of the graph.

    CausalGraph::get_all_directed_paths

    fn CausalGraph::get_all_directed_paths(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String]) -> Array[Array[String]]

    The directed paths between two singleton node sets.

    CausalGraph::get_all_nodes

    fn CausalGraph::get_all_nodes(self : CausalGraph, include_unobserved : Bool) -> Array[String]

    The nodes of the graph.

    CausalGraph::get_ancestors

    fn CausalGraph::get_ancestors(self : CausalGraph, node_name : String) ->
    Set
    [String]

    The strict ancestors of a node.

    CausalGraph::get_common_causes

    fn CausalGraph::get_common_causes(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String]) -> Array[String]

    The common causes of two node sets.

    The treatment contributes its ancestors, the outcome contributes its parents and their ancestors.

    CausalGraph::get_descendants

    fn CausalGraph::get_descendants(self : CausalGraph, nodes : Array[String]) ->
    Set
    [String]

    The strict descendants of a set of nodes.

    CausalGraph::get_effect_modifiers

    fn CausalGraph::get_effect_modifiers(self : CausalGraph, nodes1 : Array[String], nodes2 : Array[String]) -> Array[String]

    The effect modifiers of the graph.

    CausalGraph::get_instruments

    fn CausalGraph::get_instruments(self : CausalGraph, treatment_nodes : Array[String], outcome_nodes : Array[String]) -> Array[String]

    The instruments of the treatment.

    CausalGraph::get_parents

    fn CausalGraph::get_parents(self : CausalGraph, node_name : String) -> Array[String]

    The parents of a node.

    CausalGraph::has_directed_path

    fn CausalGraph::has_directed_path(self : CausalGraph, action_nodes : Array[String], outcome_nodes : Array[String]) -> Bool

    Whether every treatment reaches an outcome and vice versa.

    CausalGraph::is_observed

    fn CausalGraph::is_observed(self : CausalGraph, node_name : String) -> Bool

    Whether a node is observed.

    CausalGraph::new

    fn CausalGraph::new(treatment_name : Array[String], outcome_name : Array[String], graph : DirectedGraph?, common_cause_names : Array[String], instrument_names : Array[String], effect_modifier_names : Array[String], mediator_names : Array[String], observed_node_names : Array[String]) -> CausalGraph

    Build a causal graph.

    When graph is given it is used as is, otherwise the graph is built from the semantic roles of the variables.

    CausalGraph::observed_nodes

    fn CausalGraph::observed_nodes(self : CausalGraph) -> Array[String]

    The observed nodes of the graph.

    CausalGraph::outcomes

    fn CausalGraph::outcomes(self : CausalGraph) -> Array[String]

    The outcome variables.

    CausalGraph::treatments

    fn CausalGraph::treatments(self : CausalGraph) -> Array[String]

    The treatment variables.

    DirectedGraph

    pub struct DirectedGraph {
    nodes : Array[String]
    node_set :
    Set
    [String]
    succ : Map[String, Array[String]]
    pred : Map[String, Array[String]]
    edges : Array[(String, String)]
    }

    A directed graph, the substrate of every causal graph in the library.

    Node and edge insertion order is preserved, which keeps the generated results (adjustment sets, paths, topological orders) deterministic.

    DirectedGraph::add_edge

    fn DirectedGraph::add_edge(self : DirectedGraph, from : String, to : String) -> Unit

    Add an edge, creating the endpoints when they are new.

    DirectedGraph::add_node

    fn DirectedGraph::add_node(self : DirectedGraph, name : String) -> Unit

    Add a node, ignoring duplicates.

    DirectedGraph::all_simple_paths

    fn DirectedGraph::all_simple_paths(self : DirectedGraph, from : String, to : String) -> Array[Array[String]]

    All simple paths from from to to.

    The paths are enumerated in the order the neighbours are stored, which keeps the result deterministic.

    DirectedGraph::all_simple_paths_undirected

    fn DirectedGraph::all_simple_paths_undirected(self : DirectedGraph, from : String, to : String) -> Array[Array[String]]

    All simple paths between two nodes, ignoring the direction of the edges.

    The backdoor paths live in the underlying undirected graph, so the traversal walks both the parents and the children of a node.

    DirectedGraph::ancestors

    fn DirectedGraph::ancestors(self : DirectedGraph, name : String) ->
    Set
    [String]

    The strict ancestors of a node.

    DirectedGraph::ancestors_of

    fn DirectedGraph::ancestors_of(self : DirectedGraph, names : Array[String]) ->
    Set
    [String]

    The union of the ancestors of several nodes.

    DirectedGraph::copy

    A copy of the graph.

    DirectedGraph::descendants

    fn DirectedGraph::descendants(self : DirectedGraph, name : String) ->
    Set
    [String]

    The strict descendants of a node.

    DirectedGraph::descendants_of

    fn DirectedGraph::descendants_of(self : DirectedGraph, names : Array[String]) ->
    Set
    [String]

    The union of the descendants of several nodes.

    DirectedGraph::edge_count

    fn DirectedGraph::edge_count(self : DirectedGraph) -> Int

    The number of edges.

    DirectedGraph::edge_list

    fn DirectedGraph::edge_list(self : DirectedGraph) -> Array[(String, String)]

    The edges of the graph in insertion order.

    DirectedGraph::has_edge

    fn DirectedGraph::has_edge(self : DirectedGraph, from : String, to : String) -> Bool

    Whether the graph contains the edge.

    DirectedGraph::has_node

    fn DirectedGraph::has_node(self : DirectedGraph, name : String) -> Bool

    Whether the graph contains the node.

    DirectedGraph::has_path

    fn DirectedGraph::has_path(self : DirectedGraph, from : String, to : String) -> Bool

    Whether a path exists from from to to.

    DirectedGraph::is_dag

    fn DirectedGraph::is_dag(self : DirectedGraph) -> Bool

    Whether the graph is acyclic.

    DirectedGraph::new

    A new empty graph.

    DirectedGraph::node_count

    fn DirectedGraph::node_count(self : DirectedGraph) -> Int

    The number of nodes.

    DirectedGraph::node_list

    fn DirectedGraph::node_list(self : DirectedGraph) -> Array[String]

    The nodes of the graph in insertion order.

    DirectedGraph::predecessors

    fn DirectedGraph::predecessors(self : DirectedGraph, name : String) -> Array[String]

    The parents of a node.

    The returned array is a copy, so a caller may modify it without changing the graph.

    DirectedGraph::remove_edge

    fn DirectedGraph::remove_edge(self : DirectedGraph, from : String, to : String) -> Unit

    Remove an edge from the graph.

    DirectedGraph::subgraph

    fn DirectedGraph::subgraph(self : DirectedGraph, names : Array[String]) -> DirectedGraph

    The sub graph induced by the given nodes.

    DirectedGraph::successors

    fn DirectedGraph::successors(self : DirectedGraph, name : String) -> Array[String]

    The children of a node.

    The returned array is a copy, so a caller may modify it without changing the graph.

    DirectedGraph::to_dot

    fn DirectedGraph::to_dot(self : DirectedGraph) -> String

    The graph in Graphviz DOT format.

    DirectedGraph::topological_order

    fn DirectedGraph::topological_order(self : DirectedGraph) -> Array[String]

    A topological order of the graph.

    Returns an empty array when the graph has a cycle.

    build_graph

    fn build_graph(action_nodes : Array[String], outcome_nodes : Array[String], common_cause_nodes : Array[String], instrument_nodes : Array[String], effect_modifier_nodes : Array[String], mediator_nodes : Array[String]) -> DirectedGraph

    Build a graph from the semantic role of the variables.

    d_separated

    fn d_separated(graph : DirectedGraph, x : Array[String], y : Array[String], z : Array[String]) -> Bool

    Whether x and y are d-separated given z.

    Returns true when the two node sets are separated by the conditioning set.

    The traversal follows the classical "active path" characterisation: a path is active given z when every non collider on it is outside z and every collider on it is in z or has a descendant in z. The descendant test is what the ancestor set of z provides.

    do_surgery

    fn do_surgery(graph : DirectedGraph, node_names : Array[String], remove_outgoing_edges : Bool, remove_incoming_edges : Bool, target_node_names : Array[String], remove_only_direct_edges_to_target : Bool) -> DirectedGraph

    A graph with the edges of the given nodes removed.

    • remove_outgoing_edges drops every edge leaving the focal nodes;
    • remove_incoming_edges drops every edge entering the focal nodes;
    • remove_only_direct_edges_to_target restricts the removal to the edges that point at target_node_names.

    get_all_directed_paths

    fn get_all_directed_paths(graph : DirectedGraph, nodes1 : Array[String], nodes2 : Array[String]) -> Array[Array[String]]

    The directed paths between two singleton node sets.

    get_backdoor_paths

    fn get_backdoor_paths(graph : DirectedGraph, nodes1 : Array[String], nodes2 : Array[String]) -> Array[Array[String]]

    The backdoor paths between two node sets.

    A path is a backdoor path when its first edge points into the treatment.

    get_instruments

    fn get_instruments(graph : DirectedGraph, treatment_nodes : Array[String], outcome_nodes : Array[String]) -> Array[String]

    The instruments of the treatment, following dowhy.graph.get_instruments.

    get_proper_backdoor_graph

    fn get_proper_backdoor_graph(graph : DirectedGraph, action_nodes : Array[String], outcome_nodes : Array[String]) -> DirectedGraph

    The proper backdoor graph of the given causal graph.

    get_proper_causal_path_nodes

    fn get_proper_causal_path_nodes(graph : DirectedGraph, action_nodes : Array[String], outcome_nodes : Array[String]) ->
    Set
    [String]

    The nodes that lie on a proper causal path from the actions to the outcomes, as defined by van der Zander et al.

    has_directed_path

    fn has_directed_path(graph : DirectedGraph, action_nodes : Array[String], outcome_nodes : Array[String]) -> Bool

    Whether every treatment has a directed path to an outcome and vice versa.

    is_blocked

    fn is_blocked(graph : DirectedGraph, path : Array[String], conditioned_nodes : Array[String]) -> Bool

    Whether a path is blocked by the given conditioning set.

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io