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:
I would suggest you to first transform the graph in a AND-OR Tree. Once done you can perform a search in the tree for the best (where you can choose what "best" means: shortest, lowest memory occupation of packages in nodes, etc...) path.
A suggestion I'd make, being that the condition to install X would be something like install(X) = install(A) and (install(E) or install(C))
, is to group the OR nodes (in this case: E and C) into a single node, say EC, and transform the condition in install(X) = install(A) and install(EC)
.
In alternative, based on the AND-OR Tree idea, you could create a custom AND-OR Graph using the grouping idea. In this way you could use an adaptation of a graph traversal algorithm, which could be more useful in certain scenarios.
Yet another solution could be to use Forward Chaining. You'd have to follow these steps:
Transform (just re-writing the conditions here):
A and (E or C) => X
E and (H or Y) => A
B and (Z or Y) => E
into
(A and E) or (A and C) => X
(E and H) or (E and Y) => A
(B and Z) or (B and Y) => E
Let me know if anything is unclear.