Dependency-Graph Evaluator for Reactive Expressions

Problem Components reference each other via expressions (e.g. B = A+1, C = B*2). Given the bindings, compute a valid evaluation order, recompute only affected dependents when a value changes, and detect circular references.

Input / Output

  • Input: a set of component bindings, each an expression referencing other components.
  • Output: an evaluation order and recomputed values; an error when a cycle exists.

Requirements

  • Recompute dependents transitively when an input changes.
  • Detect and report circular references.

Areas to design

  • Representing the dependency graph and extracting referenced components from an expression.
  • Ordering evaluation so every dependency is computed before its dependents.
  • Incremental recompute on change vs. full recompute.

Example

  • B = A+1, C = B*2; A changes → recompute B then C.
added …
LeaderboardSalaryAccount