pub struct CSRGraph { /* private fields */ }Expand description
Compressed Sparse Row (CSR) format for sparse graphs
This format is highly memory-efficient for sparse graphs and provides fast row (neighbor) access.
Implementations§
Source§impl CSRGraph
impl CSRGraph
Sourcepub fn from_edges(
n_nodes: usize,
edges: Vec<(usize, usize, f64)>,
) -> Result<Self, GraphError>
pub fn from_edges( n_nodes: usize, edges: Vec<(usize, usize, f64)>, ) -> Result<Self, GraphError>
Create a new CSR graph from edge list (optimized version)
Sourcepub fn with_capacity(n_nodes: usize, estimated_edges: usize) -> Self
pub fn with_capacity(n_nodes: usize, estimated_edges: usize) -> Self
Create CSR graph with pre-allocated capacity (for streaming construction)
Sourcepub fn neighbors(&self, node: usize) -> impl Iterator<Item = (usize, f64)> + '_
pub fn neighbors(&self, node: usize) -> impl Iterator<Item = (usize, f64)> + '_
Get neighbors of a node
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get number of nodes
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Memory usage in bytes
Sourcepub fn to_adjacency_matrix(&self) -> Array2<f64>
pub fn to_adjacency_matrix(&self) -> Array2<f64>
Convert to adjacency matrix (for dense operations)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CSRGraph
impl RefUnwindSafe for CSRGraph
impl Send for CSRGraph
impl Sync for CSRGraph
impl Unpin for CSRGraph
impl UnwindSafe for CSRGraph
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