pub trait ExtendableContextuableGraph<D, S, T, ST, SYM, VS, VT>where
D: Datable + Clone,
S: Spatial<VS> + Clone,
T: Temporal<VT> + Clone,
ST: SpaceTemporal<VS, VT> + Clone,
SYM: Symbolic + Clone,
VS: Clone,
VT: Clone,{
Show 17 methods
// Required methods
fn extra_ctx_add_new(&mut self, capacity: usize, default: bool) -> u64;
fn extra_ctx_add_new_with_id(
&mut self,
id: u64,
capacity: usize,
default: bool,
) -> Result<(), ContextIndexError>;
fn extra_ctx_check_exists(&self, idx: u64) -> bool;
fn extra_ctx_get_current_id(&self) -> u64;
fn extra_ctx_set_current_id(
&mut self,
idx: u64,
) -> Result<(), ContextIndexError>;
fn extra_ctx_unset_current_id(&mut self) -> Result<(), ContextIndexError>;
fn extra_ctx_add_node(
&mut self,
value: Contextoid<D, S, T, ST, SYM, VS, VT>,
) -> Result<usize, ContextIndexError>;
fn extra_ctx_contains_node(&self, index: usize) -> bool;
fn extra_ctx_get_node(
&self,
index: usize,
) -> Result<&Contextoid<D, S, T, ST, SYM, VS, VT>, ContextIndexError>;
fn extra_ctx_remove_node(
&mut self,
index: usize,
) -> Result<(), ContextIndexError>;
fn extra_ctx_add_edge(
&mut self,
a: usize,
b: usize,
weight: RelationKind,
) -> Result<(), ContextIndexError>;
fn extra_ctx_contains_edge(&self, a: usize, b: usize) -> bool;
fn extra_ctx_remove_edge(
&mut self,
a: usize,
b: usize,
) -> Result<(), ContextIndexError>;
fn extra_ctx_size(&self) -> Result<usize, ContextIndexError>;
fn extra_ctx_is_empty(&self) -> Result<bool, ContextIndexError>;
fn extra_ctx_node_count(&self) -> Result<usize, ContextIndexError>;
fn extra_ctx_edge_count(&self) -> Result<usize, ContextIndexError>;
}Expand description
Trait for poly-contextuable causal graphs. By default, the context graph is assumed to be a single-context graph.
This trait supports multiple contexts by extending the ContextuableGraph trait.
Extends ContextuableGraph trait with methods for:
- Creating and managing additional “contexts”
- Setting a current context ID
- Context-specific node/edge methods
Provides methods for:
- Creating new contexts
- Checking if a context ID exists
- Getting/setting current context ID
- Context-specific node and edge methods
Nodes are Contextoid objects implementing required traits. Edges have a relation kind weight.
Methods return Result or Option types for error handling.
Required Methods§
Sourcefn extra_ctx_add_new(&mut self, capacity: usize, default: bool) -> u64
fn extra_ctx_add_new(&mut self, capacity: usize, default: bool) -> u64
Creates a new, empty “extra” context and adds it to the collection.
This method generates a unique ID for the new context internally.
§Parameters
capacity: The initial storage capacity to pre-allocate for the new context’s graph.default: Iftrue, the newly created context is immediately set as the currently active context for subsequentextra_ctx_*operations.
§Returns
The unique u64 ID assigned to the newly created context.
Sourcefn extra_ctx_add_new_with_id(
&mut self,
id: u64,
capacity: usize,
default: bool,
) -> Result<(), ContextIndexError>
fn extra_ctx_add_new_with_id( &mut self, id: u64, capacity: usize, default: bool, ) -> Result<(), ContextIndexError>
Creates a new extra context with a specific, user-provided ID.
This is useful for scenarios where context IDs need to be deterministic, such as when reconstructing a state from a saved configuration.
§Parameters
id: The user-definedu64ID for the new context.capacity: The initial storage capacity for the new context’s graph.default: Iftrue, this new context is set as the currently active one.
§Returns
Ok(())if the context was created successfully.
§Errors
ContextIndexErrorif a context with the providedidalready exists.
Sourcefn extra_ctx_check_exists(&self, idx: u64) -> bool
fn extra_ctx_check_exists(&self, idx: u64) -> bool
Sourcefn extra_ctx_get_current_id(&self) -> u64
fn extra_ctx_get_current_id(&self) -> u64
Gets the ID of the currently active extra context.
By convention, an ID of 0 indicates that no extra context is currently active,
and operations will target the primary context.
§Returns
The u64 ID of the active context.
Sourcefn extra_ctx_set_current_id(
&mut self,
idx: u64,
) -> Result<(), ContextIndexError>
fn extra_ctx_set_current_id( &mut self, idx: u64, ) -> Result<(), ContextIndexError>
Sets the active extra context to the one identified by the given ID.
All subsequent extra_ctx_* operations will be directed to this context
until it is changed or unset.
§Parameters
idx: Theu64ID of the context to set as active.
§Returns
Ok(())on success.
§Errors
ContextIndexErrorif no context with the specifiedidxexists.
Sourcefn extra_ctx_unset_current_id(&mut self) -> Result<(), ContextIndexError>
fn extra_ctx_unset_current_id(&mut self) -> Result<(), ContextIndexError>
Sourcefn extra_ctx_add_node(
&mut self,
value: Contextoid<D, S, T, ST, SYM, VS, VT>,
) -> Result<usize, ContextIndexError>
fn extra_ctx_add_node( &mut self, value: Contextoid<D, S, T, ST, SYM, VS, VT>, ) -> Result<usize, ContextIndexError>
Adds a Contextoid node to the currently active extra context.
This operation is directed to the context set by extra_ctx_set_current_id.
§Parameters
value: TheContextoidinstance to add to the graph.
§Returns
Ok(usize)containing the unique index of the newly added node within the active context’s graph.
§Errors
ContextIndexErrorif no extra context is currently active.
Sourcefn extra_ctx_contains_node(&self, index: usize) -> bool
fn extra_ctx_contains_node(&self, index: usize) -> bool
Checks if a node with the given index exists in the currently active extra context.
This operation is directed to the context set by extra_ctx_set_current_id.
§Parameters
index: The index of the node to check for.
§Returns
trueif a node with the specified index exists in the active context.falseif the node does not exist or if no extra context is currently active.
Sourcefn extra_ctx_get_node(
&self,
index: usize,
) -> Result<&Contextoid<D, S, T, ST, SYM, VS, VT>, ContextIndexError>
fn extra_ctx_get_node( &self, index: usize, ) -> Result<&Contextoid<D, S, T, ST, SYM, VS, VT>, ContextIndexError>
Retrieves an immutable reference to a Contextoid from the currently active extra context.
This operation is directed to the context set by extra_ctx_set_current_id.
§Parameters
index: The index of the node to retrieve.
§Returns
Ok(&Contextoid<...>)containing a reference to the node if found.
§Errors
ContextIndexErrorif no extra context is active or if theindexis out of bounds for the active context’s graph.
Sourcefn extra_ctx_remove_node(
&mut self,
index: usize,
) -> Result<(), ContextIndexError>
fn extra_ctx_remove_node( &mut self, index: usize, ) -> Result<(), ContextIndexError>
Removes a node by its index from the currently active extra context.
This operation is directed to the context set by extra_ctx_set_current_id.
Note that this will also remove all edges connected to the specified node.
§Parameters
index: The index of the node to remove.
§Returns
Ok(())if the node was successfully removed.
§Errors
ContextIndexErrorif no extra context is active or if theindexis out of bounds.
Sourcefn extra_ctx_add_edge(
&mut self,
a: usize,
b: usize,
weight: RelationKind,
) -> Result<(), ContextIndexError>
fn extra_ctx_add_edge( &mut self, a: usize, b: usize, weight: RelationKind, ) -> Result<(), ContextIndexError>
Adds a directed edge between two nodes in the currently active extra context.
The edge is created from node a to node b. This operation is directed
to the context set by extra_ctx_set_current_id.
§Parameters
a: The index of the source node.b: The index of the target node.weight: TheRelationKindthat describes the relationship between the nodes.
§Returns
Ok(())if the edge was successfully added.
§Errors
ContextIndexErrorif no extra context is active or if eitheraorbare invalid node indices.
Sourcefn extra_ctx_contains_edge(&self, a: usize, b: usize) -> bool
fn extra_ctx_contains_edge(&self, a: usize, b: usize) -> bool
Checks if a directed edge exists between two nodes in the currently active extra context.
The check is for an edge from node a to node b. This operation is directed
to the context set by extra_ctx_set_current_id.
§Parameters
a: The index of the source node.b: The index of the target node.
§Returns
trueif a directed edge fromatobexists in the active context.falseif the edge does not exist, if either index is invalid, or if no extra context is currently active.
Sourcefn extra_ctx_remove_edge(
&mut self,
a: usize,
b: usize,
) -> Result<(), ContextIndexError>
fn extra_ctx_remove_edge( &mut self, a: usize, b: usize, ) -> Result<(), ContextIndexError>
Removes a directed edge between two nodes in the currently active extra context.
This operation is directed to the context set by extra_ctx_set_current_id.
§Parameters
a: The index of the source node of the edge to remove.b: The index of the target node of the edge to remove.
§Returns
Ok(())if the edge was successfully removed.
§Errors
ContextIndexErrorif no extra context is active or if the edge does not exist.
Sourcefn extra_ctx_size(&self) -> Result<usize, ContextIndexError>
fn extra_ctx_size(&self) -> Result<usize, ContextIndexError>
Returns the number of nodes in the currently active extra context’s graph.
This operation is directed to the context set by extra_ctx_set_current_id.
§Returns
Ok(usize)containing the total number of nodes in the active context’s graph.
§Errors
ContextIndexErrorif no extra context is currently active.
Sourcefn extra_ctx_is_empty(&self) -> Result<bool, ContextIndexError>
fn extra_ctx_is_empty(&self) -> Result<bool, ContextIndexError>
Checks if the currently active extra context’s graph is empty (contains no nodes).
This operation is directed to the context set by extra_ctx_set_current_id.
§Returns
Ok(true)if the active context’s graph has zero nodes.Ok(false)if it contains one or more nodes.
§Errors
ContextIndexErrorif no extra context is currently active.
Sourcefn extra_ctx_node_count(&self) -> Result<usize, ContextIndexError>
fn extra_ctx_node_count(&self) -> Result<usize, ContextIndexError>
Returns the total number of nodes in the currently active extra context’s graph.
This operation is directed to the context set by extra_ctx_set_current_id.
§Returns
Ok(usize)containing the count of nodes in the active context’s graph.
§Errors
ContextIndexErrorif no extra context is currently active.
Sourcefn extra_ctx_edge_count(&self) -> Result<usize, ContextIndexError>
fn extra_ctx_edge_count(&self) -> Result<usize, ContextIndexError>
Returns the total number of edges in the currently active extra context’s graph.
This operation is directed to the context set by extra_ctx_set_current_id.
§Returns
Ok(usize)containing the count of edges in the active context’s graph.
§Errors
ContextIndexErrorif no extra context is currently active.