Skip to main content

Crate causasv

Crate causasv 

Source
Expand description

Fast Causal Asymmetric Shapley Values for DAGs.

§Quick Start

use causasv::{AsvExplainer, CausasvError, Dag};

fn main() -> Result<(), CausasvError> {
    let mut dag = Dag::new();
    let x = dag.add_node("X");
    let y = dag.add_node("Y");
    dag.add_edge(x, y)?;

    let explainer = AsvExplainer::new(dag);
    let result = explainer.exact(|coalition| Ok(coalition.len() as f64))?;

    for (id, val) in &result.values {
        println!("{id:?} = {val:.4}");
    }
    Ok(())
}

For large graphs use AsvExplainer::approximate or AsvExplainer::auto. See the README for Python usage and benchmarks.

Re-exports§

pub use asv::AsvExplainer;
pub use asv::AsvResult;

Modules§

asv

Structs§

Dag
Directed acyclic graph with stable node indexing.
NodeId
SamplingConfig
Configuration for approximate ASV sampling.

Enums§

CausasvError

Functions§

enumerate_topos
Enumerates ALL valid topological orderings. Output is deterministic (frontier sorted by NodeId at each step). Only practical for small graphs (n ≤ ~8).
topo_sort
Returns a valid topological ordering (smallest NodeId first among ties).

Type Aliases§

ValueFn
Type alias for a value function over node coalitions. The library guarantees the coalition slice is sorted in ascending NodeId order before calling, so callers may use it as a stable cache key.