[−][src]Struct gamma::graph::DefaultGraph
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]
fn is_empty(&self) -> bool
[src]
fn order(&self) -> usize
[src]
fn size(&self) -> usize
[src]
fn ids(&self) -> Box<dyn Iterator<Item = usize>>
[src]
fn neighbors(&self, id: usize) -> Result<Box<dyn Iterator<Item = usize>>, Error>
[src]
fn has_id(&self, id: usize) -> bool
[src]
fn degree(&self, id: usize) -> Result<usize, Error>
[src]
fn edges(&self) -> Box<dyn Iterator<Item = (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), Global>> 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, Global>, Global>> for DefaultGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for DefaultGraph
[src]
impl Send for DefaultGraph
[src]
impl Sync for DefaultGraph
[src]
impl Unpin for DefaultGraph
[src]
impl UnwindSafe for DefaultGraph
[src]
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,
pub 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.
pub 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>,