pub struct AttributedGraphBuilder<N, E> { /* private fields */ }Expand description
Builder for AttributedGraph that provides a fluent API.
§Example
use scirs2_graph::attributed_graph::{AttributedGraphBuilder, NodeId};
let mut builder: AttributedGraphBuilder<f64, f32> = AttributedGraphBuilder::new();
let a = builder.node(1.0);
let b = builder.node(2.0);
builder.edge(a, b, 0.5_f32);
let graph = builder.build().expect("build failed");
assert_eq!(graph.node_count(), 2);
assert_eq!(graph.edge_count(), 1);Implementations§
Source§impl<N, E> AttributedGraphBuilder<N, E>
impl<N, E> AttributedGraphBuilder<N, E>
Sourcepub fn with_capacity(node_capacity: usize, edge_capacity: usize) -> Self
pub fn with_capacity(node_capacity: usize, edge_capacity: usize) -> Self
Create a builder with capacity hints.
Sourcepub fn edge(&mut self, src: NodeId, dst: NodeId, data: E) -> &mut Self
pub fn edge(&mut self, src: NodeId, dst: NodeId, data: E) -> &mut Self
Add a directed edge. Any error is deferred until build.
Sourcepub fn build(self) -> Result<AttributedGraph<N, E>>
pub fn build(self) -> Result<AttributedGraph<N, E>>
Sourcepub fn build_unchecked(self) -> AttributedGraph<N, E>
pub fn build_unchecked(self) -> AttributedGraph<N, E>
Consume the builder, returning the graph without checking errors.
Silently drops any accumulated errors.
Trait Implementations§
Auto Trait Implementations§
impl<N, E> Freeze for AttributedGraphBuilder<N, E>
impl<N, E> !RefUnwindSafe for AttributedGraphBuilder<N, E>
impl<N, E> Send for AttributedGraphBuilder<N, E>
impl<N, E> Sync for AttributedGraphBuilder<N, E>
impl<N, E> Unpin for AttributedGraphBuilder<N, E>
impl<N, E> UnsafeUnpin for AttributedGraphBuilder<N, E>
impl<N, E> !UnwindSafe for AttributedGraphBuilder<N, E>
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