pub struct CausalGraph {
pub var_names: Vec<String>,
pub sep_sets: Vec<Vec<Option<Vec<usize>>>>,
/* private fields */
}Expand description
Mixed graph for causal discovery algorithms.
Each edge (i, j) is stored as a pair (mark_at_i, mark_at_j), where
mark_at_i is the mark at node i (endpoint facing node i) and
mark_at_j is the mark at node j.
- Directed edge
i → j:(Tail, Arrow)stored at entry(i, j). - Undirected edge
i — j:(Tail, Tail). - Bidirected edge
i ↔ j:(Arrow, Arrow). - Circle endpoint
i o→ j:(Circle, Arrow).
Fields§
§var_names: Vec<String>Variable names.
sep_sets: Vec<Vec<Option<Vec<usize>>>>Separation sets: sep[i][j] is the set that d-separates i and j.
Implementations§
Source§impl CausalGraph
impl CausalGraph
Sourcepub fn new(var_names: &[&str]) -> Self
pub fn new(var_names: &[&str]) -> Self
Create a new graph with the given variable names, initially fully connected.
Sourcepub fn set_edge(
&mut self,
i: usize,
j: usize,
mark_at_i: EdgeMark,
mark_at_j: EdgeMark,
)
pub fn set_edge( &mut self, i: usize, j: usize, mark_at_i: EdgeMark, mark_at_j: EdgeMark, )
Set or update an edge between i and j.
mark_at_i is the endpoint mark at node i; mark_at_j is the mark at j.
Setting an edge is symmetric: edges[i][j] and edges[j][i] are both updated.
Sourcepub fn remove_edge(&mut self, i: usize, j: usize)
pub fn remove_edge(&mut self, i: usize, j: usize)
Remove an edge between i and j.
Sourcepub fn is_adjacent(&self, i: usize, j: usize) -> bool
pub fn is_adjacent(&self, i: usize, j: usize) -> bool
Whether there is any edge between i and j.
Sourcepub fn get_mark_at(&self, from: usize, to: usize) -> Option<EdgeMark>
pub fn get_mark_at(&self, from: usize, to: usize) -> Option<EdgeMark>
Get the mark at node to on the edge from from to to.
Returns None if the edge doesn’t exist.
The returned mark is the one facing node to (i.e., the arrowhead/tail at to).
Sourcepub fn get_mark_from(&self, from: usize, to: usize) -> Option<EdgeMark>
pub fn get_mark_from(&self, from: usize, to: usize) -> Option<EdgeMark>
Get the mark at node from on the edge between from and to.
Returns None if the edge doesn’t exist.
Sourcepub fn is_directed(&self, i: usize, j: usize) -> bool
pub fn is_directed(&self, i: usize, j: usize) -> bool
Whether there is a directed edge i → j (tail at i, arrow at j).
Sourcepub fn is_undirected(&self, i: usize, j: usize) -> bool
pub fn is_undirected(&self, i: usize, j: usize) -> bool
Whether there is an undirected edge i — j (tail at both ends).
Sourcepub fn is_bidirected(&self, i: usize, j: usize) -> bool
pub fn is_bidirected(&self, i: usize, j: usize) -> bool
Whether there is a bidirected edge i ↔ j (arrow at both ends).
Sourcepub fn neighbors(&self, i: usize) -> impl Iterator<Item = usize> + '_
pub fn neighbors(&self, i: usize) -> impl Iterator<Item = usize> + '_
Return an iterator over the neighbours of node i.
Sourcepub fn get_sep_set(&self, i: usize, j: usize) -> Option<&Vec<usize>>
pub fn get_sep_set(&self, i: usize, j: usize) -> Option<&Vec<usize>>
Return the separation set for nodes i and j, if any.
Sourcepub fn set_sep_set(&mut self, i: usize, j: usize, sep: Vec<usize>)
pub fn set_sep_set(&mut self, i: usize, j: usize, sep: Vec<usize>)
Set the separation set for nodes i and j.
Sourcepub fn make_complete(&mut self)
pub fn make_complete(&mut self)
Initialize the graph as a complete undirected graph (all edges i — j).
Trait Implementations§
Source§impl Clone for CausalGraph
impl Clone for CausalGraph
Source§fn clone(&self) -> CausalGraph
fn clone(&self) -> CausalGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CausalGraph
impl RefUnwindSafe for CausalGraph
impl Send for CausalGraph
impl Sync for CausalGraph
impl Unpin for CausalGraph
impl UnsafeUnpin for CausalGraph
impl UnwindSafe for CausalGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.