Constructing ZDDs
Given a family of sets, we can find its ZDD as follows.
-
If ( is empty) return . If ( contains only the empty set) then return .
-
Find the smallest element amongst all elements in all sets of . Create a node .
-
Let be the family of all sets in not containing , that is, . Recursively construct the ZDD for , and connect the LO edge from to the root of .
-
Let be the family resulting from taking all sets in that contain and then removing from each set: . Recursively construct the ZDD for , and connect the HI edge from to the root of .
-
Look for identical nodes (same label, same LO desination and same HI destination) and combine them.
Some families have special properties allowing their ZDDs to be immediately constructed. In a universe of size , consider for example the family of all sets of size which we denote . The ZDD of is the following:
The ZDD of turns out to be easy to describe (exercise).
Here are some more examples. Let . Then the ZDD of all sets containing exactly one of is:
The ZDD of all sets containing at least one element of is:
The ZDD of all sets containing at most one element of is:
These 3 examples are readily generalized. Each can be viewed as a ZDD of all sets that branches off at the smallest element of , before joining the main branch again after the largest element of has been handled.
In many combinatorial problems, we start with families that can be immediately written down. We then perform operations on these families to construct other families which we use to solve the problem. For example, given ZDDs and , we construct , or , or , or similar.