Skip to main content

CsrMmapGraph

Struct CsrMmapGraph 

Source
pub struct CsrMmapGraph {
    pub node_count: usize,
    pub edge_count: usize,
    pub vector_dim: usize,
    pub flags: u32,
    /* private fields */
}
Expand description

Memory-mapped CSR graph reader with safe unaligned loads.

Fields§

§node_count: usize

Number of nodes in the CSR graph.

§edge_count: usize

Number of edges.

§vector_dim: usize

Embedding dimension (0 when no vectors are stored).

§flags: u32

Header flags bitfield.

Implementations§

Source§

impl CsrMmapGraph

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open and fully validate a graph.mmap file.

Source

pub fn node_id(&self, idx: usize) -> Option<&str>

Look up the node id string for a CSR index.

Source

pub fn index_of(&self, id: &str) -> Option<u32>

Look up the CSR index for a node id.

Source

pub fn node_ids(&self) -> &[String]

All node ids in CSR index order.

Source

pub fn get_neighbors(&self, node_idx: usize) -> (Vec<u32>, Vec<f32>)

Graph neighbors as owned vectors (safe, allocation per call).

Source

pub fn k_hop_neighborhood( &self, start_node_idx: usize, k: usize, ) -> Vec<(u32, f32)>

k-hop neighborhood with multiplicative path weights (first visit wins).

Source

pub fn get_vector(&self, node_idx: usize) -> Option<Vec<f32>>

Copy out the vector row for node_idx (None if no vectors).

Source

pub fn dot_product(a: &[f32], b: &[f32]) -> f32

Dot product with an unrolled loop (may auto-vectorize; not explicit SIMD).

Full scan top-k by dot product (acceptable for small N in v0.1).

Trait Implementations§

Source§

impl Debug for CsrMmapGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.