pub fn new<NI, EI>(vertices : NI, edges : EI) -> Result<Graph<V, E>, Error>
        where NI : IntoIterator<Item=(usize, V)>,
              EI : IntoIterator<Item=(usize, E, usize)>
    {
        let mut data = VecMap::new();
        for (id, vertex) in vertices {
            data.insert(id, Element {v : vertex, links : BTreeMap::new()});
        }
        for (id, edge, to) in edges {
            try!(data.get_mut(id).ok_or(Error::MissingID)).links.insert(to, edge);
        }
        Ok(Graph {
            data : data,
        })
    }
/// Create a new graph, with the given vertices and edges.
///
/// Every vertex is of the form `(id : usize, v : V)`, and every edge is of the
/// form `(from : usize, e : E, to : usize)`, which connect the vertex with index
/// `from` to the vertex with index `to`.
///
/// Returns: A new graph instance, or an error if an edge originates from a nonexisting vertex.
///
/// # Examples
/// ```
/// use graph::Graph;
/// let graph = Graph::new(
///             vec![(0, "A"), (5, "B")],
///             vec![(0, "Edge from A to B", 5)]
///     ).expect("This does not happen");
///
/// ```
Create a new graph, with the given vertices and edges.

A new graph instance, or an error if an edge originates from a nonexisting vertex.
Create a new graph with the given vertices and edges . A new graph instance or an error if an edge originates from a nonexisting vertex .
pub fn new<NI, EI>(vertices : NI, edges : EI) -> Result<Graph<V, E>, Error>
        where NI : IntoIterator<Item=(usize, V)>,
              EI : IntoIterator<Item=(usize, E, usize)>
    {
        let mut data = VecMap::new();
        for (id, vertex) in vertices {
            data.insert(id, Element {v : vertex, links : BTreeMap::new()});
        }
        for (id, edge, to) in edges {
            try!(data.get_mut(id).ok_or(Error::MissingID)).links.insert(to, edge);
        }
        Ok(Graph {
            data : data,
        })
    }
pub fn new < NI , EI > ( vertices : NI , edges : EI ) -> Result < Graph < V , E > , Error > where NI : IntoIterator < Item = ( usize , V ) > , EI : IntoIterator < Item = ( usize , E , usize ) > { let mut data = VecMap :: new ( ) ; for ( id , vertex ) in vertices { data . insert ( id , Element { v : vertex , links : BTreeMap :: new ( ) } ) ; } for ( id , edge , to ) in edges { try ! ( data get_mut ( id ) ok_or ( Error MissingID ) ) . links . insert ( to , edge ) ; } Ok ( Graph { data : data , } ) }
Create a new graph, with the given vertices and edges.
Create a new graph with the given vertices and edges .
vertices
NI
edges
EI
vertices
NI
edges
EI
examples
None