use crate::transition::*;
use core::hash::Hash;
use routers_network::{Entry, Metadata, Network};
use rustc_hash::FxHashMap;
pub trait Solver<E, M, N>
where
E: Entry,
M: Metadata,
N: Network<E, M>,
{
fn solve<Emmis, Trans>(
&self,
transition: Transition<Emmis, Trans, E, M, N>,
runtime: &M::Runtime,
) -> Result<CollapsedPath<E>, MatchError>
where
Emmis: EmissionStrategy + Send + Sync,
Trans: TransitionStrategy<E, M, N> + Send + Sync;
#[inline]
fn path_builder<K, C>(target: &K, source: &K, parents: &FxHashMap<K, (K, C)>) -> Option<Vec<K>>
where
K: Eq + Hash + Copy,
{
let mut path = vec![*target];
let mut next = target;
while next != source {
let (parent, _) = parents.get(next)?;
path.push(*parent);
next = parent;
}
path.reverse();
Some(path)
}
}