Crates.io | graphsearch |
lib.rs | graphsearch |
version | 0.6.0 |
source | src |
created_at | 2015-03-24 17:44:39.786197 |
updated_at | 2015-12-11 23:53:29.779383 |
description | A simple graph search and representation library |
homepage | |
repository | https://github.com/KarlHerler/graph |
max_upload_size | |
id | 1712 |
size | 39,188 |
graphsearch
is a simple graph library for the rust programming language.
graphsearch
can be used for basic representation and manipulation of
graph structures. At the
moment featureset is quite limited.
Here's a short basic example of using this library as an external crate:
extern crate graphsearch;
use graphsearch::{Graph, Node, Vertex};
fn main() {
let testgraph = 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 start: usize = 0;
let target = "Tampere";
let g = Graph::new(testgraph);
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));
}
}
}
This project is licensed under the MIT license, a copy of which can be found in the LICENCE file.