Builder

Trait Builder 

Source
pub trait Builder {
    type Graph: WithEdge;

    // Required methods
    fn new(n: usize, m: usize) -> Self;
    fn add_edge(&mut self, u: usize, v: usize);
    fn finalize(self) -> Self::Graph;
}
Expand description

A builder used to build graphs.

See the module documentation for examples.

Required Associated Types§

Source

type Graph: WithEdge

The graph type produced by this builder.

Required Methods§

Source

fn new(n: usize, m: usize) -> Self

Creates a new builder for a graph with exactly n vertices and initial capacity for m edges.

This method is generally called through WithBuilder::builder, for example, StaticGraph::builder(10, 26).

Source

fn add_edge(&mut self, u: usize, v: usize)

Add (u, v) edge to the graph. Support for multiple edges and loops are graph dependent.

§Panics

If u or v is not a valid vertex, that is >= num_vertices.

Source

fn finalize(self) -> Self::Graph

Builds the graph.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§