pub mod bfs;
pub mod gbfs;
use indexmap::IndexMap;
use rustc_hash::FxHasher;
use std::hash::BuildHasherDefault;
type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<FxHasher>>;
fn trace<STATE>(parents: &FxIndexMap<STATE, usize>, goal_index: usize) -> Vec<STATE>
where
STATE: Clone,
{
let mut i = goal_index;
let mut states = vec![];
loop {
let (state, parent) = parents.get_index(i).unwrap();
states.push(state.clone());
i = *parent;
if i == 0 {
states.push(parents.get_index(*parent).unwrap().0.clone());
break;
}
}
states.reverse();
states
}