I will do my best to explain what the algorithm should do:
There is a class 'Recipe'. Each Recipe may include other Recipes, but may not include itself or any other Recipe that includes it.
So, a simple example: we have only two recipes A and B.
If A first adds B, then later B cannot add A, because it will cause a loop.
More complex example:
A, B, C
(1) Recipe C adds B
(2) Recipe B adds A (3) Recipe A tries to add C, but cannot because of the relationship. C - B - A.
I can do it myself, I'm just wondering if this was a standard algorithm, and I could find the optimal solution.
thank