[−][src]Struct gamma::graph::DefaultGraph
A 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.nodes().to_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]
fn is_empty(&self) -> bool
[src]
fn order(&self) -> usize
[src]
fn size(&self) -> usize
[src]
fn nodes(&self) -> &[usize]
[src]
fn neighbors(&self, id: usize) -> Result<&[usize], Error>
[src]
fn has_node(&self, id: usize) -> bool
[src]
fn degree(&self, id: usize) -> Result<usize, Error>
[src]
fn edges(&self) -> &[(usize, usize)]
[src]
fn has_edge(&self, sid: usize, tid: usize) -> Result<bool, Error>
[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.
fn try_from(traversal: DepthFirst<'a, G>) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<(usize, usize)>> for DefaultGraph
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(edges: Vec<(usize, usize)>) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<Vec<usize>>> for DefaultGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for DefaultGraph
impl Send for DefaultGraph
impl Sync for DefaultGraph
impl Unpin for DefaultGraph
impl UnwindSafe for DefaultGraph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,