Spreadsheet circular reference (source code)

= Spreadsheet circular reference

A <spreadsheet cell> depends on itself along a nonempty <directed path>. For a separate formula-edit experiment, restore the initial inputs and replace only `B1` by `=A1+A2+C1`. Now `B1` $\to$ `C1` $\to$ `B1` is a <directed cycle>. Requesting `D1` makes `D1,C1,B1` active and then requests the still-active `C1`; the <algorithm> reports `C1,B1,C1` rather than returning an old value. This witness follows references backwards, opposite to our dependency arrows; reversing it gives a <directed cycle> in the <spreadsheet dependency graph>.

`D1` is not itself on that <directed cycle>, but it cannot receive a value from this evaluator because it needs `C1`. Independent requests for `B2` and `E1` still succeed. A <topological order> of the entire modified <spreadsheet dependency graph> is impossible: the two cyclic <directed edges> would require `B1` before `C1` and `C1` before `B1`. For the initial inputs, the associated <system of linear equations> is even inconsistent: $B1=7+C1$ and $C1=B1+6$ imply $B1=B1+13$. Detecting a <directed cycle> is a structural check, not an attempt to solve these <linear equations>.