mod model;
mod network;
mod vecmap;
mod weight;
pub mod bfs;
pub mod locate;
pub mod misc;
pub mod si;
pub use model::Model;
pub use network::Network;
pub use weight::Weight;
pub mod cn {
pub use crate::vecmap::VecMap;
pub use crate::vecmap::VecSet;
use rustc_hash::FxHasher;
use std::hash::BuildHasherDefault as Builder;
pub type IndexMap<K, V> = indexmap::IndexMap<K, V, Builder<FxHasher>>;
pub type IndexSet<T> = indexmap::IndexSet<T, Builder<FxHasher>>;
pub trait Iter<I>: DoubleEndedIterator<Item = I> {}
impl<T: DoubleEndedIterator + Iterator<Item = I>, I> Iter<I> for T {}
#[derive(Debug, PartialEq)]
pub enum Err {
NoSuchNode(usize),
BadWeight(f64),
LinkToSelf(usize),
BadProbability(f64),
NodeExists(usize),
NoTarget,
NotWhole,
}
pub type Result<T> = std::result::Result<T, Err>;
impl std::fmt::Display for Err {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let message = match self {
Err::NoSuchNode(i) => format!("No such node {}", i),
Err::BadWeight(w) => format!("Link weight cannot be {}", w),
Err::LinkToSelf(i) => format!("Attempted linking node {} to itself", i),
Err::BadProbability(p) => format!("Probability cannot be {}", p),
Err::NodeExists(i) => format!("Node {} already exists", i),
Err::NoTarget => "No search targets were specified".to_string(),
Err::NotWhole => "The network must be whole".to_string(),
};
write!(f, "{}", message)
}
}
impl std::error::Error for Err {}
}