pub struct FactorGraph { /* private fields */ }Expand description
Factor graph representation for PGM.
Implementations§
Source§impl FactorGraph
impl FactorGraph
Sourcepub fn add_variable(&mut self, name: String, domain: String)
pub fn add_variable(&mut self, name: String, domain: String)
Add a variable to the graph.
Sourcepub fn add_variable_with_card(
&mut self,
name: String,
domain: String,
cardinality: usize,
)
pub fn add_variable_with_card( &mut self, name: String, domain: String, cardinality: usize, )
Add a variable with specific cardinality.
Sourcepub fn add_factor(&mut self, factor: Factor) -> Result<()>
pub fn add_factor(&mut self, factor: Factor) -> Result<()>
Add a factor to the graph.
Sourcepub fn add_factor_from_predicate(
&mut self,
name: &str,
var_names: &[String],
) -> Result<()>
pub fn add_factor_from_predicate( &mut self, name: &str, var_names: &[String], ) -> Result<()>
Add a factor from predicate name and variables.
Sourcepub fn get_variable(&self, name: &str) -> Option<&VariableNode>
pub fn get_variable(&self, name: &str) -> Option<&VariableNode>
Get variable node.
Sourcepub fn get_factor(&self, id: &str) -> Option<&Factor>
pub fn get_factor(&self, id: &str) -> Option<&Factor>
Get factor.
Sourcepub fn get_adjacent_factors(&self, var: &str) -> Option<&Vec<String>>
pub fn get_adjacent_factors(&self, var: &str) -> Option<&Vec<String>>
Get factors connected to a variable.
Sourcepub fn get_adjacent_variables(&self, factor_id: &str) -> Option<&Vec<String>>
pub fn get_adjacent_variables(&self, factor_id: &str) -> Option<&Vec<String>>
Get variables connected to a factor.
Sourcepub fn num_variables(&self) -> usize
pub fn num_variables(&self) -> usize
Get number of variables.
Sourcepub fn num_factors(&self) -> usize
pub fn num_factors(&self) -> usize
Get number of factors.
Sourcepub fn variable_names(&self) -> impl Iterator<Item = &String>
pub fn variable_names(&self) -> impl Iterator<Item = &String>
Get all variable names.
Sourcepub fn factor_ids(&self) -> impl Iterator<Item = &String>
pub fn factor_ids(&self) -> impl Iterator<Item = &String>
Get all factor IDs.
Sourcepub fn variables(&self) -> impl Iterator<Item = (&String, &VariableNode)>
pub fn variables(&self) -> impl Iterator<Item = (&String, &VariableNode)>
Get all variables as an iterator.
Sourcepub fn get_all_factors(&self) -> Vec<&Factor>
pub fn get_all_factors(&self) -> Vec<&Factor>
Get all factors as a vector (for external use).
Trait Implementations§
Source§impl Clone for FactorGraph
impl Clone for FactorGraph
Source§fn clone(&self) -> FactorGraph
fn clone(&self) -> FactorGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FactorGraph
impl Debug for FactorGraph
Source§impl Default for FactorGraph
impl Default for FactorGraph
Source§impl QuantRSModelExport for FactorGraph
impl QuantRSModelExport for FactorGraph
Source§fn to_quantrs_model(&self) -> Result<ModelExport>
fn to_quantrs_model(&self) -> Result<ModelExport>
Export the model to a QuantRS-compatible format.
Source§fn model_stats(&self) -> ModelStatistics
fn model_stats(&self) -> ModelStatistics
Get model statistics for QuantRS integration.
Auto Trait Implementations§
impl Freeze for FactorGraph
impl RefUnwindSafe for FactorGraph
impl Send for FactorGraph
impl Sync for FactorGraph
impl Unpin for FactorGraph
impl UnwindSafe for FactorGraph
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more