pub struct CausaloidGraph<T: Clone> { /* private fields */ }Expand description
A specialized graph structure for representing and reasoning about causal relationships.
CausaloidGraph is a wrapper around an ultragraph graph, tailored for holding
nodes that implement the Causable trait. This structure allows for modeling
complex, non-linear causal systems where the activation of one cause can influence
others in a directed, potentially acyclic, manner.
The graph uses an adjacency matrix for its underlying storage, which provides fast edge lookups but can be memory-intensive if the graph is sparse and has a large capacity.
§Type Parameters
T: The type of the nodes in the graph. It must implementCausableto allow for causal reasoning,PartialEqfor node comparison,Cloneto manage graph data, andDisplayfor explanations. A commonTis theCausaloidstruct.
Implementations§
Source§impl<T: Clone> CausaloidGraph<T>
impl<T: Clone> CausaloidGraph<T>
Sourcepub fn new(id: IdentificationValue) -> Self
pub fn new(id: IdentificationValue) -> Self
Creates a new CausaloidGraph with a default capacity.
This constructor initializes the graph with a default capacity of 500 nodes. It utilizes an adjacency matrix for storage, which is suitable for dense graphs or graphs where the maximum number of nodes is known and not excessively large.
§Returns
Sourcepub fn new_with_capacity(id: IdentificationValue, capacity: usize) -> Self
pub fn new_with_capacity(id: IdentificationValue, capacity: usize) -> Self
Creates a new CausaloidGraph with a specified capacity.
This constructor allows you to pre-allocate space for a given number of nodes, which can be beneficial for performance if the approximate size of the graph is known beforehand. The underlying storage uses an adjacency matrix.
§Arguments
capacity- The maximum number of nodes the graph is expected to hold.
Trait Implementations§
Source§impl<I, O, PS, C> CausableGraph<Causaloid<I, O, PS, C>> for CausaloidGraph<Causaloid<I, O, PS, C>>
impl<I, O, PS, C> CausableGraph<Causaloid<I, O, PS, C>> for CausaloidGraph<Causaloid<I, O, PS, C>>
fn is_frozen(&self) -> bool
Source§fn freeze(&mut self)
fn freeze(&mut self)
Static state. Read moreSource§fn get_graph(&self) -> &UltraGraphWeighted<Causaloid<I, O, PS, C>, u64>
fn get_graph(&self) -> &UltraGraphWeighted<Causaloid<I, O, PS, C>, u64>
CausalGraph. Read moreSource§fn add_root_causaloid(
&mut self,
value: Causaloid<I, O, PS, C>,
) -> Result<usize, CausalityGraphError>
fn add_root_causaloid( &mut self, value: Causaloid<I, O, PS, C>, ) -> Result<usize, CausalityGraphError>
Source§fn contains_root_causaloid(&self) -> bool
fn contains_root_causaloid(&self) -> bool
Source§fn get_root_causaloid(&self) -> Option<&Causaloid<I, O, PS, C>>
fn get_root_causaloid(&self) -> Option<&Causaloid<I, O, PS, C>>
Source§fn get_root_index(&self) -> Option<usize>
fn get_root_index(&self) -> Option<usize>
Source§fn get_last_index(&self) -> Result<usize, CausalityGraphError>
fn get_last_index(&self) -> Result<usize, CausalityGraphError>
Source§fn add_causaloid(
&mut self,
value: Causaloid<I, O, PS, C>,
) -> Result<usize, CausalityGraphError>
fn add_causaloid( &mut self, value: Causaloid<I, O, PS, C>, ) -> Result<usize, CausalityGraphError>
Source§fn contains_causaloid(&self, index: usize) -> bool
fn contains_causaloid(&self, index: usize) -> bool
Source§fn get_causaloid(&self, index: usize) -> Option<&Causaloid<I, O, PS, C>>
fn get_causaloid(&self, index: usize) -> Option<&Causaloid<I, O, PS, C>>
Source§fn remove_causaloid(
&mut self,
index: usize,
) -> Result<(), CausalGraphIndexError>
fn remove_causaloid( &mut self, index: usize, ) -> Result<(), CausalGraphIndexError>
Source§fn add_edge(&mut self, a: usize, b: usize) -> Result<(), CausalGraphIndexError>
fn add_edge(&mut self, a: usize, b: usize) -> Result<(), CausalGraphIndexError>
Source§fn add_edg_with_weight(
&mut self,
a: usize,
b: usize,
weight: u64,
) -> Result<(), CausalGraphIndexError>
fn add_edg_with_weight( &mut self, a: usize, b: usize, weight: u64, ) -> Result<(), CausalGraphIndexError>
Source§fn remove_edge(
&mut self,
a: usize,
b: usize,
) -> Result<(), CausalGraphIndexError>
fn remove_edge( &mut self, a: usize, b: usize, ) -> Result<(), CausalGraphIndexError>
Source§fn size(&self) -> usize
fn size(&self) -> usize
Source§fn number_edges(&self) -> usize
fn number_edges(&self) -> usize
Source§fn number_nodes(&self) -> usize
fn number_nodes(&self) -> usize
Source§fn get_shortest_path(
&self,
start_index: usize,
stop_index: usize,
) -> Result<Vec<usize>, CausalityGraphError>
fn get_shortest_path( &self, start_index: usize, stop_index: usize, ) -> Result<Vec<usize>, CausalityGraphError>
Source§impl<T: Clone + Clone> Clone for CausaloidGraph<T>
impl<T: Clone + Clone> Clone for CausaloidGraph<T>
Source§fn clone(&self) -> CausaloidGraph<T>
fn clone(&self) -> CausaloidGraph<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more