pub struct Adjacency {
pub n: usize,
pub out: Vec<Vec<(usize, f32)>>,
pub inc: Vec<Vec<(usize, f32)>>,
pub und: Vec<Vec<(usize, f32)>>,
}Expand description
A built adjacency over n indexed nodes: directed out / in neighbour lists plus an
undirected view, each carrying an edge weight (1.0 for unweighted input). Built
once from (n, edges) and shared by the analysis algorithms.
Fields§
§n: usizeNode count (indices 0..n).
out: Vec<Vec<(usize, f32)>>out[i] = directed out-neighbours of i as (j, weight).
inc: Vec<Vec<(usize, f32)>>inc[i] = directed in-neighbours of i as (j, weight).
und: Vec<Vec<(usize, f32)>>und[i] = undirected neighbours of i as (j, weight) (each edge both ways).
Implementations§
Source§impl Adjacency
impl Adjacency
Sourcepub fn from_edges(n: usize, edges: &[(usize, usize)]) -> Self
pub fn from_edges(n: usize, edges: &[(usize, usize)]) -> Self
Build from unweighted directed edges (each (a, b) has weight 1.0).
Out-of-range endpoints and self-loops are dropped.
Sourcepub fn from_weighted(n: usize, edges: &[(usize, usize, f32)]) -> Self
pub fn from_weighted(n: usize, edges: &[(usize, usize, f32)]) -> Self
Build from weighted directed edges. Out-of-range endpoints and self-loops are dropped; parallel edges accumulate their weight.
Sourcepub fn out_degree(&self, i: usize) -> usize
pub fn out_degree(&self, i: usize) -> usize
Out-degree of i (count of distinct out-neighbours).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Adjacency
impl RefUnwindSafe for Adjacency
impl Send for Adjacency
impl Sync for Adjacency
impl Unpin for Adjacency
impl UnsafeUnpin for Adjacency
impl UnwindSafe for Adjacency
Blanket Implementations§
impl<T> Allocation for T
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