[][src]Struct gamma::graph::DefaultGraph

pub struct DefaultGraph { /* fields omitted */ }

An undirected Graph backed by an adjacency matrix. Nodes and neighbors are iterated in the order in which they're added.

use std::convert::TryFrom;
use gamma::graph::{ Graph, Error, DefaultGraph };
 
fn main() -> Result<(), Error> {
    let mut c3 = DefaultGraph::try_from(vec![
        vec![ 1 ],
        vec![ 0, 2 ],
        vec![ 1 ]
    ])?;
 
    assert_eq!(c3.ids().collect::<Vec<_>>(), vec![ 0, 1, 2 ]);
 
    assert_eq!(c3.add_edge(0, 1), Err(Error::DuplicateEdge(0, 1)));
 
    Ok(())
}

Implementations

impl DefaultGraph[src]

pub fn new() -> Self[src]

pub fn add_node(&mut self, id: usize) -> Result<(), Error>[src]

pub fn add_edge(&mut self, sid: usize, tid: usize) -> Result<(), Error>[src]

Trait Implementations

impl Debug for DefaultGraph[src]

impl Graph for DefaultGraph[src]

impl PartialEq<DefaultGraph> for DefaultGraph[src]

impl<'a, G: Graph> TryFrom<DepthFirst<'a, G>> for DefaultGraph[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Vec<(usize, usize), Global>> for DefaultGraph[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Vec<Vec<usize, Global>, Global>> for DefaultGraph[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.