Crate graphsearch [−] [src]
A graph representation and search library
Example
use graphsearch::{Graph, Node, Vertex}; let rawgraph = vec![Node{content: "Helsinki", adjacent: vec![Vertex{cost: 20, node: 1}, Vertex{cost: 50, node: 2}]}, Node{content: "Turku", adjacent: vec![Vertex{cost: 30, node: 2}]}, Node{content: "Tampere", adjacent: Vec::new()}]; let g = Graph::new(rawgraph); let start = 0; let target = "Tampere"; let res = g.search(start, target); // uses dijkstras algorithm match res { None => { println!("Search returned None"); } Some(result) => { println!("Search returned a path: {:?}", result); println!("The returned path cost: {}", g.cost_of_path(&result)); } }
Structs
Graph |
A graph, represeted by as a weighted
Adjacency list of |
Node |
A node in the graph, made up a any content type |
Vertex |
A vertex between two |