Struct hadean_std::graph::GraphInterpreter [] [src]

pub struct GraphInterpreter<T>(_) where T: Eq + Hash + ProcessSendable;

Interpret a Graph<V,E> using arbitrary vertex identifiers supplied to GraphConstructor. Here's an example of building a graph from Strings and interpreting it:

use hadean_std::graph::{GraphConstructor,Graph,GraphInterpreter};

let mut graph_constructor: GraphConstructor<String,_,f64,()> = GraphConstructor::new(|_|0.0);
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<f64,()>, GraphInterpreter<String>) = graph_constructor.construct();
let rankmap: HashMap<String, f64> = graph_interpreter.interpret(graph);
for (name,score) in rankmap {
    println!("{}: {}", name, score);
}

Methods

impl<T> GraphInterpreter<T> where T: Eq + Hash + ProcessSendable
[src]

fn interpret<V, E>(self, graph: Graph<V, E>) -> HashMap<T, V> where V: ProcessSendable, E: ProcessSendable

Interprets a Graph<V,E> and returns a HashMap mapping vertex identifiers to vertex associated data.