Struct hadean_std::graph::GraphConstructor
[−]
[src]
pub struct GraphConstructor<T, F, V, E> where T: Eq + Hash + ProcessSendable, F: Fn(&T) -> V + ProcessSendable, V: ProcessSendable, E: ProcessSendable {
// some fields omitted
}Construct a Graph<V,E> from arbitrary vertex identifiers.
Here's an example of building a graph from Strings:
use hadean_std::graph::{GraphConstructor,Graph,GraphInterpreter}; let mut graph_constructor: GraphConstructor<String,_,(),()> = GraphConstructor::new(|_|()); graph_constructor.push(String::from("http://google.com"), String::from("https://hadean.com"), ()); graph_constructor.push(String::from("http://bbc.co.uk"), String::from("https://hadean.com"), ()); graph_constructor.push(String::from("https://hadean.com"), String::from("http://alecmocatta.com"), ()); let (graph, graph_interpreter): (Graph<(),()>, GraphInterpreter<String>) = graph_constructor.construct();
Methods
impl<T, F, V, E> GraphConstructor<T, F, V, E> where T: Eq + Hash + ProcessSendable, F: Fn(&T) -> V + ProcessSendable, V: ProcessSendable, E: ProcessSendable[src]
fn new(v: F) -> GraphConstructor<T, F, V, E>
Constructs a new, empty GraphConstructor<T,F,V,E>. v generates initial vertex associated data.
fn push(&mut self, a: T, b: T, e: E)
Add an edge between two vertex identifiers a and b, where e is the edge associated data.
fn construct(self) -> (Graph<V, E>, GraphInterpreter<T>)
Constructs a Graph<V,E> upon which algorithms can be run, and a GraphInterpreter<T> which can be used to interpret the graph with the vertex identifiers.