Legion6789
asked on
How do you perform a circular reference check?
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).
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).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do
set assigndays to false
for all entries
if Day == -1
if no reference
set Day to Offset
set assigndays to true
else
if Day at item reference != -1
set Day to Day at item reference plus Offset
set assigndays to true
while assigndays
set problem to false
for all entries
if Day == -1 set problem to true