Crate luka[][src]

Expand description

Library for working with graphs

Example

use luka::Graph;
use luka::utils;
use luka::algorithms;

let mut graph = Graph::new(100);

graph.add_edge(1, 2, 0).unwrap();
graph.add_edge(1, 3, 0).unwrap();
graph.add_edge(2, 4, 0).unwrap();
graph.add_edge(3, 4, 0).unwrap();
graph.add_edge(4, 5, 0).unwrap();

let start = graph.get_vertex(1).unwrap();
let target = graph.get_vertex(17).unwrap();
let parents = algorithms::bfs(&graph, &start).unwrap();
match utils::find_path(&graph, &target, &parents).unwrap() {
    Some(path) => {
        assert_eq!(path.iter().map(|vertex|vertex.id()).collect::<Vec<usize>>(), vec![1, 2, 4, 8, 17]);
    }
    None => {
       println!("Path not found !!!")
    }
}

Modules

Structs