Details
Description
We need a function to detect circular references whenever a calculation has been edited:
detect_circular_reference(array) => boolean
The array is a whole lot of calculation strings containing verified idnumber strings for all the calcualtions in a course, eg:
C= A + B
A = B + C
B = C + A
See Double Loop on this page for an algorithm: http://phrogz.net/nodes/traversingdirectedgraph.asp
Added one file that contains one topological_sorter()
it provides one solution to find the correct patch for recalculating all the formulas following dependencies and, if some cyclic is found, returns false.
So, applying it when adding/modifying/deleting formulas will provide instantly the path to follow and any cyclic if found.
Hope it helps...ciao