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

pub trait Builder where
    Self: Sized
{ type Graph; type Node: Copy + Eq; type Edge: Copy + Eq; fn with_capacities(nnodes: usize, nedges: usize) -> Self;
fn reserve(&mut self, nnodes: usize, nedges: usize);
fn num_nodes(&self) -> usize;
fn num_edges(&self) -> usize;
fn add_node(&mut self) -> Self::Node;
fn add_edge(&mut self, u: Self::Node, v: Self::Node) -> Self::Edge;
fn node2id(&self, u: Self::Node) -> usize;
fn edge2id(&self, e: Self::Edge) -> usize;
fn into_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

type Graph[src]

The graph type produced by this builder.

type Node: Copy + Eq[src]

The type of a nodes.

type Edge: Copy + Eq[src]

The type of an edge.

Loading content...

Required methods

fn with_capacities(nnodes: usize, nedges: usize) -> Self[src]

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.

fn reserve(&mut self, nnodes: usize, nedges: usize)[src]

Reserve memory for a certain number of nodes and edges.

fn num_nodes(&self) -> usize[src]

Return the current number of nodes.

fn num_edges(&self) -> usize[src]

Return the current number of nodes.

fn add_node(&mut self) -> Self::Node[src]

Add a new node.

fn add_edge(&mut self, u: Self::Node, v: Self::Node) -> Self::Edge[src]

Add a new edge.

fn node2id(&self, u: Self::Node) -> usize[src]

Return a unique id of a node.

fn edge2id(&self, e: Self::Edge) -> usize[src]

Return a unique id of an edge.

fn into_graph(self) -> Self::Graph[src]

Turn the builder into a graph.

Loading content...

Provided methods

fn new() -> Self[src]

Create a new, empty builder.

fn add_nodes(&mut self, n: usize) -> Vec<Self::Node>[src]

Add n new nodes.

Loading content...

Implementors

impl<'b, B, G, Gx, Nx, Ex> Builder for AttributedBuilder<B, Gx, Nx, Ex> where
    B: Builder<Graph = G>,
    G: GraphSize<'b>,
    Gx: Default,
    Nx: Default,
    Ex: Default
[src]

type Graph = Attributed<G, Gx, Nx, Ex>

type Node = B::Node

type Edge = B::Edge

impl<ID> Builder for VecGraphBuilder<ID> where
    ID: PrimInt + Unsigned
[src]

type Graph = VecGraph<ID>

type Node = Node<ID>

type Edge = Edge<ID>

impl<ID, N, E> Builder for LinkedListGraphBuilder<ID, N, E> where
    ID: PrimInt + Unsigned,
    N: Default,
    E: Default
[src]

type Graph = LinkedListGraph<ID, N, E>

type Node = Node<ID>

type Edge = Edge<ID>

Loading content...