mod heaps;
mod models;
mod shortest_path;
pub use models::{Edge, Graph};
pub use shortest_path::ShortestPath;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_bmssp_sample_1() {
let mut graph = vec![Vec::new(), Vec::new(), Vec::new(), Vec::new()];
graph[0].push(Edge::new(1, 1.0));
graph[0].push(Edge::new(2, 4.0));
graph[1].push(Edge::new(2, 2.0));
graph[1].push(Edge::new(3, 5.0));
graph[2].push(Edge::new(3, 1.0));
let mut sp = ShortestPath::new(graph);
let distances = sp.get(0);
assert_eq!(distances[0], 0.0);
assert_eq!(distances[1], 1.0);
assert_eq!(distances[2], 3.0);
assert_eq!(distances[3], 4.0);
}
#[test]
fn test_bmssp_sample_2() {
let mut graph = vec![Vec::new(), Vec::new(), Vec::new(), Vec::new()];
graph[0].push(Edge::new(1, 1.0));
graph[0].push(Edge::new(2, 4.0));
graph[2].push(Edge::new(0, 1.0));
graph[1].push(Edge::new(2, 2.0));
graph[3].push(Edge::new(1, 1.0));
graph[3].push(Edge::new(2, 5.0));
let mut sp = ShortestPath::new(graph);
let distances = sp.get(1);
assert_eq!(distances[0], 3.0);
assert_eq!(distances[1], 0.0);
assert_eq!(distances[2], 2.0);
assert_eq!(distances[3], f32::INFINITY);
}
}