pub struct CsrMutableEdges { /* private fields */ }Expand description
Mutable edge storage combining CSR base with delta slab
Provides efficient edge mutations with automatic rebuild when delta grows too large.
Implementations§
Source§impl CsrMutableEdges
impl CsrMutableEdges
Sourcepub fn with_coords(coords: Vec<AbsCoord>) -> Self
pub fn with_coords(coords: Vec<AbsCoord>) -> Self
Create with initial vertex coordinates
Sourcepub fn add_edge(&mut self, from: VertexId, to: VertexId)
pub fn add_edge(&mut self, from: VertexId, to: VertexId)
Add an edge, rebuilding if threshold reached
Sourcepub fn remove_edge(&mut self, from: VertexId, to: VertexId)
pub fn remove_edge(&mut self, from: VertexId, to: VertexId)
Remove an edge, rebuilding if threshold reached
Sourcepub fn out_edges(&self, v: VertexId) -> Vec<VertexId>
pub fn out_edges(&self, v: VertexId) -> Vec<VertexId>
Get outgoing edges for a vertex (merged view)
Sourcepub fn out_edges_ref(&self, v: VertexId) -> Option<&[VertexId]>
pub fn out_edges_ref(&self, v: VertexId) -> Option<&[VertexId]>
Borrow outgoing edges when no delta mutations are pending.
This is a zero-allocation hot path for read-heavy evaluation/scheduling phases.
Sourcepub fn in_edges(&self, v: VertexId) -> &[VertexId]
pub fn in_edges(&self, v: VertexId) -> &[VertexId]
Get incoming edges from base CSR (delta not applied for performance) After rebuild, this will include all changes
Sourcepub fn in_edges_ref(&self, v: VertexId) -> Option<&[VertexId]>
pub fn in_edges_ref(&self, v: VertexId) -> Option<&[VertexId]>
Borrow incoming edges when no delta mutations are pending.
This is a zero-allocation hot path for read-heavy evaluation/scheduling phases.
Sourcepub fn delta_size(&self) -> usize
pub fn delta_size(&self) -> usize
Get the current delta size
Sourcepub fn num_edges_exact(&self) -> usize
pub fn num_edges_exact(&self) -> usize
Return the exact number of logical outgoing dependency edges, including pending delta mutations.
This is intended for read-only observability. When the delta slab is non-empty, the implementation walks the known vertex ids and merges each outgoing edge list, so callers should avoid putting it on hot evaluation paths.
Sourcepub fn begin_batch(&mut self)
pub fn begin_batch(&mut self)
Enter batch mode - defer rebuilds until the outer end_batch() call.
Sourcepub fn add_vertex(&mut self, coord: AbsCoord, vertex_id: u32) -> usize
pub fn add_vertex(&mut self, coord: AbsCoord, vertex_id: u32) -> usize
Add a new vertex with its coordinate and ID
Sourcepub fn add_vertices_batch(&mut self, items: &[(AbsCoord, u32)])
pub fn add_vertices_batch(&mut self, items: &[(AbsCoord, u32)])
Add many vertices at once; single rebuild at end.
Sourcepub fn update_coord(&mut self, vertex_id: VertexId, new_coord: AbsCoord)
pub fn update_coord(&mut self, vertex_id: VertexId, new_coord: AbsCoord)
Update coordinate for a vertex in the cache Marks for rebuild to maintain sort order
Sourcepub fn adjacency_with_carried_forward_edges(
&self,
adjacency: Vec<(u32, Vec<u32>)>,
) -> Vec<(u32, Vec<u32>)>
pub fn adjacency_with_carried_forward_edges( &self, adjacency: Vec<(u32, Vec<u32>)>, ) -> Vec<(u32, Vec<u32>)>
Return a copy of adjacency extended with the current base+delta
out-edges of every existing vertex that the input does not cover.
Named-range pass-through vertices (NamedScalar/NamedArray) emit edges
to their underlying cells via add_edge during load; those edges live
in base/delta but are not part of the formula-target adjacency that
bulk-ingest’s finalize hands to [build_from_adjacency]. Feeding the
raw adjacency straight to that (pure) builder would therefore silently
drop the pass-through vertices’ out-edges, and build_demand_subgraph
could never reach the underlying cells. Callers run this first to merge
those edges back in, then pass the result to build_from_adjacency.
Must be called BEFORE build_from_adjacency, which overwrites
base/delta/vertex_ids.
Sourcepub fn build_from_adjacency(
&mut self,
adjacency: Vec<(u32, Vec<u32>)>,
coords: Vec<AbsCoord>,
vertex_ids: Vec<u32>,
)
pub fn build_from_adjacency( &mut self, adjacency: Vec<(u32, Vec<u32>)>, coords: Vec<AbsCoord>, vertex_ids: Vec<u32>, )
Build underlying CSR directly from adjacency and provided coords/ids. This replaces the current base and clears the delta slab.
Pure builder: it uses exactly the edges in adjacency and does not
consult the existing base/delta. To preserve edges for vertices
absent from adjacency (e.g. named-range pass-through vertices), run
[adjacency_with_carried_forward_edges] first and pass its result in.
Trait Implementations§
Source§impl Debug for CsrMutableEdges
impl Debug for CsrMutableEdges
Auto Trait Implementations§
impl Freeze for CsrMutableEdges
impl RefUnwindSafe for CsrMutableEdges
impl Send for CsrMutableEdges
impl Sync for CsrMutableEdges
impl Unpin for CsrMutableEdges
impl UnsafeUnpin for CsrMutableEdges
impl UnwindSafe for CsrMutableEdges
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
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