I\'m working on an algorithm which goal is to find a minimum set of packages to install package \"X\".
I\'ll explain better with an example:
My code is here.
Scenario:
Represent the constraints.
X : A&(E|C)
A : E&(Y|N)
E : B&(Z|Y)
C : A|K
Prepare two variables target and result. Add the node X to target.
target = X, result=[]
Add single node X to the result. Replace node X with its dependent in the target.
target = A&(E|C), result=[X]
Add single node A to result. Replace node A with its dependent in the target.
target = E&(Y|N)&(E|C), result=[X, A]
Single node E must be true. So (E|C) is always true. Remove it from the target.
target = E&(Y|N), result=[X, A]
Add single node E to result. Replace node E with its dependent in the target.
target = B&(Z|Y)&(Y|N), result=[X, A, E]
Add single node B to result. Replace node B with its dependent in the target.
target = (Z|Y)&(Y|N), result=[X, A, E, B]
There are no single nodes any more. Then expand the target expression.
target = Z&Y|Z&N|Y&Y|Y&N, result=[X, A, E, B]
Replace Y&Y to Y.
target = Z&Y|Z&N|Y|Y&N, result=[X, A, E, B]
Choose the term that has smallest number of nodes. Add all nodes in the term to the target.
target = , result=[X, A, E, B, Y]