pub struct SimilarityMatrix { /* private fields */ }Expand description
Similarity matrix between nodes of two graphs.
Stores an [n1 x n2] matrix where entry (i, j) represents the similarity
between node i in graph 1 and node j in graph 2.
Implementations§
Source§impl SimilarityMatrix
impl SimilarityMatrix
Sourcepub fn new(n1: usize, n2: usize) -> Result<Self>
pub fn new(n1: usize, n2: usize) -> Result<Self>
Create a new similarity matrix initialized to uniform values 1 / (n1 * n2).
§Errors
Returns an error if either dimension is zero.
Sourcepub fn from_prior(prior: Array2<f64>) -> Result<Self>
pub fn from_prior(prior: Array2<f64>) -> Result<Self>
Create a similarity matrix from a prior similarity array.
The prior is normalized so that all entries sum to 1.
§Errors
Returns an error if the prior has zero dimensions or all-zero entries.
Sourcepub fn get(&self, i: usize, j: usize) -> f64
pub fn get(&self, i: usize, j: usize) -> f64
Get the similarity between node i in G1 and node j in G2.
Returns 0.0 if indices are out of bounds.
Sourcepub fn set(&mut self, i: usize, j: usize, value: f64)
pub fn set(&mut self, i: usize, j: usize, value: f64)
Set the similarity between node i in G1 and node j in G2.
Does nothing if indices are out of bounds.
Trait Implementations§
Source§impl Clone for SimilarityMatrix
impl Clone for SimilarityMatrix
Source§fn clone(&self) -> SimilarityMatrix
fn clone(&self) -> SimilarityMatrix
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 moreAuto Trait Implementations§
impl Freeze for SimilarityMatrix
impl RefUnwindSafe for SimilarityMatrix
impl Send for SimilarityMatrix
impl Sync for SimilarityMatrix
impl Unpin for SimilarityMatrix
impl UnsafeUnpin for SimilarityMatrix
impl UnwindSafe for SimilarityMatrix
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