pub struct CsrGraphBuilder { /* private fields */ }Expand description
Builder for constructing CSR graphs from edge lists.
Accumulates edges and then performs a single sort + prefix-sum to build the CSR arrays efficiently.
Implementations§
Source§impl CsrGraphBuilder
impl CsrGraphBuilder
Sourcepub fn new(num_nodes: usize, directed: bool) -> Self
pub fn new(num_nodes: usize, directed: bool) -> Self
Create a new CSR graph builder.
§Arguments
num_nodes- Number of nodes in the graphdirected- Whether the graph is directed
Sourcepub fn with_capacity(
num_nodes: usize,
edge_capacity: usize,
directed: bool,
) -> Self
pub fn with_capacity( num_nodes: usize, edge_capacity: usize, directed: bool, ) -> Self
Create a builder with pre-allocated edge capacity.
Sourcepub fn add_edge(&mut self, src: usize, dst: usize, weight: f64) -> Result<()>
pub fn add_edge(&mut self, src: usize, dst: usize, weight: f64) -> Result<()>
Add a single edge.
For undirected graphs, the reverse edge is added automatically during build.
Sourcepub fn add_unweighted_edge(&mut self, src: usize, dst: usize) -> Result<()>
pub fn add_unweighted_edge(&mut self, src: usize, dst: usize) -> Result<()>
Add an unweighted edge (weight = 1.0).
Sourcepub fn add_edges<I>(&mut self, edges: I) -> Result<()>
pub fn add_edges<I>(&mut self, edges: I) -> Result<()>
Add edges from an iterator of (src, dst, weight) triples.
Sourcepub fn build_parallel(self) -> Result<CsrGraph>
pub fn build_parallel(self) -> Result<CsrGraph>
Build the CSR graph using parallel sorting and construction.
Trait Implementations§
Source§impl Clone for CsrGraphBuilder
impl Clone for CsrGraphBuilder
Source§fn clone(&self) -> CsrGraphBuilder
fn clone(&self) -> CsrGraphBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CsrGraphBuilder
impl RefUnwindSafe for CsrGraphBuilder
impl Send for CsrGraphBuilder
impl Sync for CsrGraphBuilder
impl Unpin for CsrGraphBuilder
impl UnsafeUnpin for CsrGraphBuilder
impl UnwindSafe for CsrGraphBuilder
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> 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>
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