[−][src]Struct gamma::graph::HashGraph
A Graph backed by an adjacency map. Nodes will not necessarily be iterated in numerical order, but all iteration orders are stable. As such, HashGraph works well when extracting subgraphs from other graphs.
use gamma::graph::{ Graph, HashGraph, Error, Step }; fn main() -> Result<(), Error> { let c3 = HashGraph::from_traversal(0, vec![ Step::new(0, 1, false), Step::new(1, 2, false), Step::new(2, 0, true) ])?; assert_eq!(c3.nodes().to_vec(), vec![ 0, 1, 2 ]); let result = HashGraph::from_traversal(0, vec![ Step::new(0, 1, false), Step::new(1, 0, false) ]); assert_eq!(result, Err(Error::DuplicateEdge(1, 0))); Ok(()) }
Implementations
impl HashGraph
[src]
pub fn from_traversal(root: usize, steps: Vec<Step>) -> Result<Self, Error>
[src]
Builds from a traversal. Returns an error given:
- a Step source has not been seen before
- duplicate edge forward or reversed
pub fn from_edges(
edges: Vec<(usize, usize)>,
singletons: Vec<usize>
) -> Result<Self, Error>
[src]
edges: Vec<(usize, usize)>,
singletons: Vec<usize>
) -> Result<Self, Error>
Builds a node-induced subgraph from edges. Returns error given:
- duplicate edge forward or reversed
Trait Implementations
impl Debug for HashGraph
[src]
impl Graph for HashGraph
[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<HashGraph> for HashGraph
[src]
impl StructuralPartialEq for HashGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for HashGraph
impl Send for HashGraph
impl Sync for HashGraph
impl Unpin for HashGraph
impl UnwindSafe for HashGraph
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>,