pub trait WeightedGraphRef {
// Required methods
fn node_count(&self) -> usize;
fn neighbors_and_weights_ref(&self, node: usize) -> (&[usize], &[f32]);
// Provided method
fn out_degree(&self, node: usize) -> usize { ... }
}Expand description
Weighted graph view returning borrowed (neighbors, weights) slice pairs.
Mirrors the CSR-style representation used by node2vec / PecanPy: each node
owns contiguous neighbor and weight lists of equal length, indexed in
parallel. Prefer this over WeightedGraph for operators that iterate
over the same node’s neighbors many times (biased walks, alias sampling).
Required Methods§
Sourcefn node_count(&self) -> usize
fn node_count(&self) -> usize
Number of nodes in the graph. Must be stable across calls.
Sourcefn neighbors_and_weights_ref(&self, node: usize) -> (&[usize], &[f32])
fn neighbors_and_weights_ref(&self, node: usize) -> (&[usize], &[f32])
Borrow (neighbors, weights) for a node, where the two slices are
indexed in parallel: weights[i] is the weight of the edge to
neighbors[i].
Invariants:
neighbors.len() == weights.len()- Weights should be non-negative (required for node2vec / node2vec+). Negative weights produce undefined sampling behavior.
Provided Methods§
Sourcefn out_degree(&self, node: usize) -> usize
fn out_degree(&self, node: usize) -> usize
Number of out-neighbors of node. Default delegates to the neighbor slice.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".