Trait rs_graph::builder::Builder [] [src]

pub trait Builder where
    Self: Sized
{ type Graph; type Node: Node; type Edge: Edge; fn with_capacities(nnodes: usize, nedges: usize) -> Self;
fn reserve(&mut self, nnodes: usize, nedges: usize);
fn add_node(&mut self) -> Self::Node;
fn add_edge(&mut self, u: Self::Node, v: Self::Node) -> Self::Edge;
fn node_id(&self, u: Self::Node) -> usize;
fn edge_id(&self, e: Self::Edge) -> usize;
fn to_graph(self) -> Self::Graph; fn new() -> Self { ... }
fn add_nodes(&mut self, n: usize) -> Vec<Self::Node> { ... } }

A trait to construct graphs.

In general graphs are static objects. In order to build a graph, one should use a graph builder and, once the construction is complete, convert it into a graph.

This 2-level approach is used because some graph implementations be unstable if the graph is modified (e.g., the node numbers might change). The builder approach allows to separate construction and use of a graph.

Associated Types

The graph type produced by this builder.

The type of a nodes.

The type of an edge.

Required Methods

Create a new, empty builder.

The builder might be passed a guess of the number of nodes and edges. This might be used to reserve the appropriate internal memory, but is no strict requirement for the number of nodes and edges to be added to the graph.

Reserve memory for a certain number of nodes and edges.

Add a new node.

Add a new edge.

Return a unique id of a node.

Return a unique id of an edge.

Turn the builder into a graph.

Provided Methods

Create a new, empty builder.

Add n new nodes.

Implementors