def test_reduce_combined(): """Fig.5 in 1986 Bryant TOC""" ordering = {'x': 0, 'y': 1, 'z': 2} g = BDD(ordering) g.roots.add(2) g._succ[2] = (0, 3, 4) g._succ[3] = (1, -1, 5) g._succ[4] = (1, 5, 6) g._succ[5] = (2, -1, 1) g._succ[6] = (2, -1, 1) h = g.reduction() assert 1 in h assert ordering == h.ordering r = nx.MultiDiGraph() r.add_node(1, level=3) r.add_node(2, level=0) r.add_node(3, level=1) r.add_node(4, level=2) r.add_edge(2, 3, value=False, complement=False) r.add_edge(2, 4, value=True, complement=False) r.add_edge(3, 4, value=True, complement=False) r.add_edge(3, 1, value=False, complement=True) r.add_edge(4, 1, value=False, complement=True) r.add_edge(4, 1, value=True, complement=False) (u, ) = h.roots compare(u, h, r)
def test_elimination(): ordering = {'x': 0, 'y': 1} g = BDD(ordering) g.roots.add(2) # high == low, so node 2 is redundant g._succ[2] = (0, 3, 3) g._succ[3] = (1, -1, 1) h = g.reduction() assert set(h) == {1, 2}
def test_isomorphism(): ordering = {'x': 0} g = BDD(ordering) g.roots.update([2, 3]) g._succ[2] = (0, -1, 1) g._succ[3] = (0, -1, 1) h = g.reduction() assert set(h) == {1, 2}, set(h) assert 0 not in h assert h._succ[1] == (1, None, None) assert h._succ[2] == (0, -1, 1) assert h.roots == {2}