I have a series of items that can be emailed. The trigger for when to send each item can be based on an event. One possible event is the sending of another item. For example: Item 3 is sent 10 days after Item 2. I can see how one could check for a simple circular reference such as Item 1 is sent 10 days before item 2 and item 2 is sent 30 days after item 1. But how would one check for more complicated circular references such as:
Item1: Send 10 days before Item2
Item2: Send 30 days after Item4
Item3: Send 20 days after Item5
Item4 Send 10 days before Item2
Item5 Send 5 days after Item4
Basically I need an algorithm that could determine if its a circular reference and if not, calculate the hard dates for all of these (obviously one item would have to have some sort of fixed date for the others to be calculated from).