pub struct SparseDistanceMatrix { /* private fields */ }Expand description
Compressed Sparse Row (CSR) matrix for efficient sparse distance storage
Implementations§
Source§impl SparseDistanceMatrix
impl SparseDistanceMatrix
Sourcepub fn new(n_rows: usize, n_cols: usize, symmetric: bool) -> Self
pub fn new(n_rows: usize, n_cols: usize, symmetric: bool) -> Self
Create a new empty sparse distance matrix
§Arguments
n_rows- Number of rowsn_cols- Number of columnssymmetric- Whether the matrix should be symmetric
Sourcepub fn from_data(
data: &Array2<Float>,
config: SparseMatrixConfig,
) -> Result<Self>
pub fn from_data( data: &Array2<Float>, config: SparseMatrixConfig, ) -> Result<Self>
Create sparse distance matrix from dense data
§Arguments
data- Input data matrix (n_samples × n_features)config- Configuration for sparse matrix creation
Sourcepub fn set(&mut self, row: usize, col: usize, value: Float) -> Result<()>
pub fn set(&mut self, row: usize, col: usize, value: Float) -> Result<()>
Set the value at position (row, col)
Note: This is an expensive operation for CSR matrices as it may require rebuilding the entire structure. Use during construction only.
Sourcepub fn neighbors_within_radius(
&self,
row: usize,
radius: Float,
) -> Vec<(usize, Float)>
pub fn neighbors_within_radius( &self, row: usize, radius: Float, ) -> Vec<(usize, Float)>
Get all neighbors within a specific radius
Sourcepub fn to_dense(&self) -> Array2<Float>
pub fn to_dense(&self) -> Array2<Float>
Convert to dense matrix (for small matrices or debugging)
Sourcepub fn stats(&self) -> SparseMatrixStats
pub fn stats(&self) -> SparseMatrixStats
Get matrix statistics
Sourcepub fn is_symmetric(&self) -> bool
pub fn is_symmetric(&self) -> bool
Check if matrix is symmetric
Sourcepub fn connected_components(&self) -> Vec<usize>
pub fn connected_components(&self) -> Vec<usize>
Advanced: Get connected components using union-find algorithm Returns vector where each element is the component ID for that vertex
Sourcepub fn graph_diameter(&self) -> Option<usize>
pub fn graph_diameter(&self) -> Option<usize>
Advanced: Compute graph diameter (longest shortest path) Uses BFS from multiple starting points for efficiency
Sourcepub fn clustering_coefficient(&self, vertex: usize) -> Float
pub fn clustering_coefficient(&self, vertex: usize) -> Float
Advanced: Compute clustering coefficient for a vertex Measures how connected a vertex’s neighbors are to each other
Sourcepub fn average_clustering_coefficient(&self) -> Float
pub fn average_clustering_coefficient(&self) -> Float
Advanced: Compute average clustering coefficient for the entire graph
Trait Implementations§
Source§impl Clone for SparseDistanceMatrix
impl Clone for SparseDistanceMatrix
Source§fn clone(&self) -> SparseDistanceMatrix
fn clone(&self) -> SparseDistanceMatrix
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SparseDistanceMatrix
impl RefUnwindSafe for SparseDistanceMatrix
impl Send for SparseDistanceMatrix
impl Sync for SparseDistanceMatrix
impl Unpin for SparseDistanceMatrix
impl UnwindSafe for SparseDistanceMatrix
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
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>
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
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.