Trait MoralGraph

Source
pub trait MoralGraph: IntoUndirectedGraph {
    type MoralGraph: UndirectedGraph<Direction = Undirected>;

    // Required method
    fn moral(&self) -> Self::MoralGraph;
}
Expand description

Moral graph trait.

Required Associated Types§

Source

type MoralGraph: UndirectedGraph<Direction = Undirected>

Associated moral graph type.

Required Methods§

Source

fn moral(&self) -> Self::MoralGraph

Build a moral graph.

§Examples
use itertools::Itertools;

use causal_hub::prelude::*;
use causal_hub::models::MoralGraph;

// Build a new directed graph.
let g = DiGraph::new(
    ["A", "B", "C", "D", "E"],
    [("A", "C"), ("B", "C")]
);

// Build the associated moral graph.
let h = g.moral();

// Assert previous parents are connected.
for x in V!(g) {
    for (y, z) in Pa!(g, x).tuple_windows() {
        assert!(h.has_edge(y, z));
    }
}

Implementors§