[][src]Struct gamma::graph::HashGraph

pub struct HashGraph { /* fields omitted */ }

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]

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]

impl PartialEq<HashGraph> for HashGraph[src]

impl StructuralPartialEq for HashGraph[src]

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.