pub struct GraphStorage {
pub out_edges: Vec<Vec<GraphEdge>>,
pub in_edges: Vec<Vec<GraphEdge>>,
pub degrees: Vec<Precision>,
}Expand description
Graph adjacency list storage format.
Optimized for graph algorithms like push methods.
Fields§
§out_edges: Vec<Vec<GraphEdge>>Outgoing edges for each node
in_edges: Vec<Vec<GraphEdge>>Incoming edges for each node (for backward push)
degrees: Vec<Precision>Node degrees for normalization
Implementations§
Source§impl GraphStorage
impl GraphStorage
Sourcepub fn from_triplets(
triplets: Vec<(usize, usize, Precision)>,
nodes: DimensionType,
) -> Result<Self>
pub fn from_triplets( triplets: Vec<(usize, usize, Precision)>, nodes: DimensionType, ) -> Result<Self>
Create graph storage from triplets.
Sourcepub fn get(&self, row: usize, col: usize) -> Option<Precision>
pub fn get(&self, row: usize, col: usize) -> Option<Precision>
Get matrix element at (row, col).
Sourcepub fn row_iter(&self, row: usize) -> GraphRowIter<'_> ⓘ
pub fn row_iter(&self, row: usize) -> GraphRowIter<'_> ⓘ
Iterate over non-zero elements in a row.
Sourcepub fn col_iter(&self, col: usize) -> GraphColIter<'_> ⓘ
pub fn col_iter(&self, col: usize) -> GraphColIter<'_> ⓘ
Iterate over non-zero elements in a column.
Sourcepub fn multiply_vector(&self, x: &[Precision], result: &mut [Precision])
pub fn multiply_vector(&self, x: &[Precision], result: &mut [Precision])
Matrix-vector multiplication: result = A * x
Sourcepub fn multiply_vector_add(&self, x: &[Precision], result: &mut [Precision])
pub fn multiply_vector_add(&self, x: &[Precision], result: &mut [Precision])
Matrix-vector multiplication with accumulation: result += A * x
Sourcepub fn to_triplets(&self) -> Result<Vec<(usize, usize, Precision)>>
pub fn to_triplets(&self) -> Result<Vec<(usize, usize, Precision)>>
Extract as coordinate triplets.
Sourcepub fn add_diagonal(&mut self, alpha: Precision)
pub fn add_diagonal(&mut self, alpha: Precision)
Add a value to the diagonal.
Sourcepub fn out_neighbors(&self, node: usize) -> &[GraphEdge]
pub fn out_neighbors(&self, node: usize) -> &[GraphEdge]
Get outgoing edges for a node.
Sourcepub fn in_neighbors(&self, node: usize) -> &[GraphEdge]
pub fn in_neighbors(&self, node: usize) -> &[GraphEdge]
Get incoming edges for a node.
Trait Implementations§
Source§impl Clone for GraphStorage
impl Clone for GraphStorage
Source§fn clone(&self) -> GraphStorage
fn clone(&self) -> GraphStorage
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 GraphStorage
impl Debug for GraphStorage
Source§impl<'de> Deserialize<'de> for GraphStorage
impl<'de> Deserialize<'de> for GraphStorage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GraphStorage
impl RefUnwindSafe for GraphStorage
impl Send for GraphStorage
impl Sync for GraphStorage
impl Unpin for GraphStorage
impl UnwindSafe for GraphStorage
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