i am looking for a nice algorithm to solve the following problem.
I have the following listing of VARIABLES and FORMULAS (result of var is the sum of all formulas):
var1, result=10
- 5+5=10
var2, result=15
- var1+5
var3, result=30
- var1+var2+5
now i am looking for a nice way to calculate all references. if i am changing var1 and the result is 15 now, i have to calculate all referenced to var1. first i came across var2 and recalc var2, if the result of var2 changed i have to recalc all referenced formulas to var2. therefore i would recalc var3 twice (var2 changed, var1 changed)...
is there any solution to not calc var3 twice in this scenario?
thx!