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.