best-path 0.1.1

Shortest/longest path algorithms, where edge weight accumulation via either a sum or a product
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
#[cfg(not(feature = "std"))]
use alloc::vec;
use crate::types::*;
use crate::*;

/// Mock PathCalculator which only provides paths of already known pairs.
pub struct NoBestPathCalculator {}
impl<C: Currency, A: Amount, P: Provider> BestPathCalculator<C, A, P> for NoBestPathCalculator {
	fn calc_best_paths(pairs_and_prices: &[(ProviderPair<C, P>, A)]) -> Result<PricePathGraph<C, A, P>, CalculatorError> {
		Ok(pairs_and_prices.iter().cloned().map(|(pp, price)| (Pair{source: pp.pair.source, target: pp.pair.target}, PricePath{total_cost: price, steps: vec![]})).collect())
	}
}