1
0
mirror of https://github.com/ellmau/adf-obdd.git synced 2025-12-19 09:29:36 +01:00

RESOLV todo on variable-lists (#32)

variable lists can now be queried - regardless of the given features
This commit is contained in:
Stefan Ellmauthaler 2022-03-04 17:25:08 +01:00 committed by GitHub
parent 7cf581cd9b
commit a68c584a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 4 deletions

View File

@ -614,7 +614,6 @@ mod test {
let _adf = Adf::default(); let _adf = Adf::default();
} }
#[cfg(feature = "variablelist")]
#[test] #[test]
fn facet_counts() { fn facet_counts() {
let parser = AdfParser::default(); let parser = AdfParser::default();

View File

@ -113,6 +113,11 @@ impl Var {
pub fn value(self) -> usize { pub fn value(self) -> usize {
self.0 self.0
} }
/// Returns true if the value of the variable is a constant (i.e. Top or Bot)
pub fn is_constant(&self) -> bool {
self.value() >= Var::BOT.value()
}
} }
/// A [BddNode] is representing one Node in the decision diagram /// A [BddNode] is representing one Node in the decision diagram
@ -216,6 +221,17 @@ mod test {
assert_eq!(*node.var(), var); assert_eq!(*node.var(), var);
assert_eq!(*node.lo(), lo); assert_eq!(*node.lo(), lo);
assert_eq!(*node.hi(), hi); assert_eq!(*node.hi(), hi);
match node.var() {
Var::TOP => {
assert!(node.var().is_constant());
}
Var::BOT => {
assert!(node.var().is_constant());
}
val => {
assert!(!val.is_constant());
}
}
true true
} }
} }

View File

@ -323,10 +323,18 @@ impl Bdd {
} }
#[cfg(not(feature = "variablelist"))] #[cfg(not(feature = "variablelist"))]
{ {
let _ = tree; let node = self.nodes[tree.value()];
HashSet::new() if node.var().is_constant() {
return HashSet::new();
}
let mut var_set = self
.var_dependencies(node.lo())
.union(&self.var_dependencies(node.hi()))
.copied()
.collect::<HashSet<Var>>();
var_set.insert(node.var());
var_set
} }
// TODO!
} }
} }