pub struct CsrAdjacency { /* private fields */ }Expand description
Read-optimized compressed sparse row adjacency for graph traversal.
Memory layout for N entities with E total edges:
- Forward:
row_offsets[N+1]+targets[E]+edge_tags[E] - Reverse: separate CSR indexed by target ref_val
refs_from(eid) is a single slice: targets[row_offsets[eid]..row_offsets[eid+1]]
Implementations§
Source§impl CsrAdjacency
impl CsrAdjacency
Sourcepub fn from_ref_adjacency(adj: &RefAdjacency, max_entity_id: usize) -> Self
pub fn from_ref_adjacency(adj: &RefAdjacency, max_entity_id: usize) -> Self
Build a CSR snapshot from the mutable HashMap-based adjacency.
Sourcepub fn targets_from(
&self,
entity_id: usize,
ref_type: Option<&str>,
) -> Vec<String>
pub fn targets_from( &self, entity_id: usize, ref_type: Option<&str>, ) -> Vec<String>
Get target ref values from an entity, optionally filtered by ref type.
Returns a contiguous slice view (no allocation for unfiltered case).
Sourcepub fn sources_to(
&self,
target_ref_val: &str,
ref_type: Option<&str>,
) -> Vec<usize>
pub fn sources_to( &self, target_ref_val: &str, ref_type: Option<&str>, ) -> Vec<usize>
Get source entity ids that reference target_ref_val, optionally
filtered by ref type.
Sourcepub fn targets_from_patched(
&self,
entity_id: usize,
ref_type: Option<&str>,
patch: &CsrPatch,
) -> Vec<String>
pub fn targets_from_patched( &self, entity_id: usize, ref_type: Option<&str>, patch: &CsrPatch, ) -> Vec<String>
Get targets from an entity, overlaying a patch buffer.
Sourcepub fn sources_to_patched(
&self,
target_ref_val: &str,
ref_type: Option<&str>,
patch: &CsrPatch,
) -> Vec<usize>
pub fn sources_to_patched( &self, target_ref_val: &str, ref_type: Option<&str>, patch: &CsrPatch, ) -> Vec<usize>
Get source entity IDs that reference target, overlaying a patch buffer.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Total number of forward edges stored.
Auto Trait Implementations§
impl Freeze for CsrAdjacency
impl RefUnwindSafe for CsrAdjacency
impl Send for CsrAdjacency
impl Sync for CsrAdjacency
impl Unpin for CsrAdjacency
impl UnsafeUnpin for CsrAdjacency
impl UnwindSafe for CsrAdjacency
Blanket Implementations§
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
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>
Converts
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>
Converts
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