steiner tree: eliminate identity loops

This commit is contained in:
Michael Sippel 2024-12-24 12:54:43 +01:00
parent f61605a865
commit 23810c16e2
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 11 additions and 10 deletions

View file

@ -65,7 +65,7 @@ impl<M: Morphism + Clone> MorphismBase<M> {
&m.get_type().src_type,
&src_type.clone().normalize()
) {
let dst_type =
let dst_type =
m.get_type().dst_type.clone()
.apply_substitution( &|x| σ.get(x).cloned() )
.clone();
@ -185,6 +185,7 @@ impl<M: Morphism + Clone> MorphismBase<M> {
None
}
/// finde a morphism that matches the given morphism type
pub fn find_morphism(&self, ty: &MorphismType)
-> Option< ( M, HashMap<TypeID, TypeTerm> ) > {
@ -255,4 +256,3 @@ impl<M: Morphism + Clone> MorphismBase<M> {
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\

View file

@ -34,7 +34,7 @@ impl SteinerTree {
let mut new_goals = Vec::new();
let mut added = false;
for g in self.goals.clone() {
for g in self.goals.clone() {
if let Ok(σ) = crate::unify(&ty.dst_type, &g) {
if !added {
self.edges.push(ty.clone());
@ -107,8 +107,13 @@ impl PathApproxSteinerTreeSolver {
let mut new_path_iter = new_path.into_iter().peekable();
// check all existing nodes..
if new_path_iter.peek().unwrap() == &src_type {
new_path_iter.next();
}
for mt in tree.iter() {
// assert!( mt.src_type == &src_type );
//assert!( mt.src_type == &src_type );
if let Some(t) = new_path_iter.peek() {
if &mt.dst_type == t {
// eliminate this node from new path
@ -196,7 +201,7 @@ impl SteinerTreeProblem {
pub fn solve_approx_path<M: Morphism + Clone>(&mut self, morphisms: &MorphismBase<M>) -> Option< SteinerTree > {
if let Some(master) = self.src_types.first() {
}
}
*/
@ -238,4 +243,3 @@ impl SteinerTreeProblem {
None
}
}

View file

@ -14,8 +14,6 @@ pub enum TypeTerm {
Num(i64),
Char(char),
/* Complex Terms */
// Type Parameters
@ -47,10 +45,9 @@ impl TypeTerm {
*self = TypeTerm::App(vec![
self.clone(),
t.into()
])
])
}
}
self
}