pub struct GraphCsr {
pub n: usize,
pub offsets: Vec<u32>,
pub targets: Vec<u32>,
pub weights: Vec<f32>,
}Expand description
CSR (compressed-sparse-row) adjacency + per-node weight — the GPU-streamable
graph. offsets[i]..offsets[i+1] indexes into targets for node i’s
neighbours; weights[i] is node i’s mass. The three Vecs map 1:1 onto the
three GPU storage buffers (offsets/targets read-only, weights packed into
the node buffer), so this is the upload format — no repack at the seam.
Fields§
§n: usize§offsets: Vec<u32>Length n + 1. offsets[i]..offsets[i+1] = node i’s slice of targets.
targets: Vec<u32>Neighbour node indices (undirected: each input edge contributes both ways).
weights: Vec<f32>Per-node mass / importance (default 1.0). Streamed from an Arrow weight column.
Implementations§
Source§impl GraphCsr
impl GraphCsr
Sourcepub fn from_edges(
n: usize,
edges: &[(u32, u32)],
weights: Option<&[f32]>,
) -> Self
pub fn from_edges( n: usize, edges: &[(u32, u32)], weights: Option<&[f32]>, ) -> Self
Build CSR from a directed edge list (from,to node indices) over n
nodes. Layout forces are undirected, so each edge attracts both endpoints
(the targets row holds both directions); self-loops + out-of-range ids are
dropped, and parallel edges are de-duplicated. weights (per node) default to
1.0 when None or short.
The edges are exactly the (src, dst) pairs an Arrow edge RecordBatch
exposes (Int64 columns cast to u32); [GraphCsr::from_arrow] is the
zero-glue Arrow front door over this.
Sourcepub fn degree_sum(&self) -> usize
pub fn degree_sum(&self) -> usize
The number of undirected adjacency entries (= 2 × distinct edges).
Sourcepub fn neighbours(&self, i: usize) -> &[u32]
pub fn neighbours(&self, i: usize) -> &[u32]
Node i’s neighbour slice.
Trait Implementations§
impl StructuralPartialEq for GraphCsr
Auto Trait Implementations§
impl Freeze for GraphCsr
impl RefUnwindSafe for GraphCsr
impl Send for GraphCsr
impl Sync for GraphCsr
impl Unpin for GraphCsr
impl UnsafeUnpin for GraphCsr
impl UnwindSafe for GraphCsr
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more