本文整理匯總了Python中dd.bdd.BDD.descendants方法的典型用法代碼示例。如果您正苦於以下問題:Python BDD.descendants方法的具體用法?Python BDD.descendants怎麽用?Python BDD.descendants使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dd.bdd.BDD
的用法示例。
在下文中一共展示了BDD.descendants方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_descendants
# 需要導入模塊: from dd.bdd import BDD [as 別名]
# 或者: from dd.bdd.BDD import descendants [as 別名]
def test_descendants():
ordering = dict(x=0, y=1)
b = BDD(ordering)
u = b.add_expr('x && y')
v = b.add_expr('x | y')
roots = [u, v]
nodes = b.descendants(roots)
nodes_u = b.descendants([u])
nodes_v = b.descendants([v])
assert u in nodes_u, nodes_u
assert v in nodes_v, nodes_v
assert u in nodes, nodes
assert v in nodes, nodes
assert 1 in nodes_u, nodes_u
assert 1 in nodes_v, nodes_v
assert 1 in nodes, nodes
assert len(nodes_u) == 3, nodes_u
assert len(nodes_v) == 3, nodes_v
assert nodes_u != nodes_v, (nodes_u, nodes_v)
assert len(nodes) == 4, nodes
assert nodes == nodes_u.union(nodes_v), (
nodes, b._succ)
# no roots
roots = []
nodes = b.descendants(roots)
assert len(nodes) == 0, nodes