diff --git a/reCTBN/src/structure_learning/constraint_based_algorithm.rs b/reCTBN/src/structure_learning/constraint_based_algorithm.rs index 6fd5b79..d94c793 100644 --- a/reCTBN/src/structure_learning/constraint_based_algorithm.rs +++ b/reCTBN/src/structure_learning/constraint_based_algorithm.rs @@ -48,6 +48,7 @@ impl StructureLearningAlgorithm for CTPC

{ .collect(); let mut b = 0; while b < candidate_parent_set.len() { + let mut not_parent_node: usize = child_node; for parent_node in candidate_parent_set.iter() { for separation_set in candidate_parent_set .iter() @@ -62,16 +63,30 @@ impl StructureLearningAlgorithm for CTPC

{ *parent_node, &separation_set, &mut self.cache, - ) && self.Chi2test.call(&net, child_node, *parent_node, &separation_set, &mut self.cache) { - candidate_parent_set.remove(&parent_node); + ) && self.Chi2test.call( + &net, + child_node, + *parent_node, + &separation_set, + &mut self.cache, + ) { + not_parent_node = parent_node.clone(); break; } } + if not_parent_node != child_node { + break; + } + } + if not_parent_node != child_node { + candidate_parent_set.remove(¬_parent_node); } b = b + 1; } + for parent_node in candidate_parent_set.iter() { + net.add_edge(*parent_node, child_node); + } } - net } }