Skip to main content

CausalGraph

Struct CausalGraph 

Source
pub struct CausalGraph { /* private fields */ }
Expand description

v0.44: a directed acyclic graph over findings, derived from the link graph. Edges point from a finding to its declared parent (the finding it depends on / supports / cites as evidence).

We materialize parents and children both for fast lookup. The graph is built lazily from a Project; updates require rebuilding.

Implementations§

Source§

impl CausalGraph

Source

pub fn from_project(project: &Project) -> Self

Build the causal graph from a project’s link graph. Walks every finding’s links array; depends and supports link types contribute directed edges from source to target. contradicts, extends, and other link types are excluded — they don’t encode causal dependency.

Source

pub fn node_count(&self) -> usize

Number of nodes in the graph.

Source

pub fn edge_count(&self) -> usize

Number of directed edges in the graph.

Source

pub fn contains(&self, node: &str) -> bool

True iff the node exists in the graph.

Source

pub fn parents_of(&self, node: &str) -> impl Iterator<Item = &str>

Direct parents of node (findings that node depends on).

Source

pub fn children_of(&self, node: &str) -> impl Iterator<Item = &str>

Direct children of node (findings that depend on node).

Source

pub fn ancestors(&self, node: &str) -> HashSet<String>

All ancestors of node (transitive closure of parents).

Source

pub fn descendants(&self, node: &str) -> HashSet<String>

All descendants of node (transitive closure of children). Includes node itself only if requested.

Source

pub fn is_descendant_of(&self, candidate: &str, source: &str) -> bool

True iff candidate is a descendant of source (transitive).

Source

pub fn paths_between( &self, start: &str, end: &str, max_paths: usize, max_len: usize, ) -> Vec<Vec<String>>

All undirected paths between start and end, capped at max_paths and max_len. A path is a sequence of distinct nodes; each consecutive pair is connected by either a parent or child edge (we walk the graph as undirected for path enumeration; direction matters for the d-separation check).

Returns paths as Vec<Vec<String>>, where each inner Vec is the node sequence from start to end.

Source

pub fn is_path_blocked(&self, path: &[String], z: &HashSet<String>) -> bool

True iff path is d-separated by Z. A path is blocked by Z if any non-endpoint node on the path satisfies one of:

  • chain or fork: node is in Z
  • collider: neither node nor any descendant of node is in Z

Equivalently, path is open under Z iff every chain/fork node is not in Z, AND every collider node is in Z (or has a descendant in Z).

Source

pub fn is_back_door_path(&self, path: &[String], x: &str) -> bool

True iff the path is a “back-door path” from x to y: it begins at x with an incoming edge to x (i.e., the second node is a parent of x), not an outgoing edge.

Source

pub fn is_directed_path(&self, path: &[String]) -> bool

v0.44.2: True iff every consecutive edge in path points from the earlier node to the later node (i.e., the path is a directed path in the DAG, not a mixed undirected walk). Required for the front-door criterion’s “M intercepts every directed path source → target” check.

Trait Implementations§

Source§

impl Clone for CausalGraph

Source§

fn clone(&self) -> CausalGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CausalGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more