Graph<TNodeValue extends GraphNodeValue> class
DAG of GraphNodeValues with a three-state cascade state machine.
Graph owns:
- Structure (parent/child edges, cycle detection at construction).
- Per-node status (GraphNodeStatus).
- Cascade ordering: parallel sibling activation with parent-before- child ordering; reverse-topological deactivation.
- Serialization: resolve and recompute chain through a single in-flight cascade future so rapid calls are observed in order.
- Centralized error reporting: all visitor exceptions are caught and routed through GraphVisitor.onError.
The visitor (see GraphVisitor) supplies the policy (target state) and side effects (on-activate / on-deactivate).
Constructors
-
Graph({required List<
TNodeValue> nodeValues, required GraphVisitor<TNodeValue> visitor, int? activationConcurrency, int drainIterationLimit = 64}) -
Constructs a graph over
nodeValueswithvisitorfor cascade policy/side-effects.
Properties
- drainIterationLimit → int
-
Upper bound on the drain loop applied by resolve — captured
from the
drainIterationLimitconstructor parameter.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isShutdown → bool
-
Whether shutdown has been invoked. Subsequent resolve / recompute
calls throw
StateError.no setter -
rootNodes
→ Set<
GraphNode< TNodeValue> > -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
descendantsInTopologicalOrder(
TNodeValue root) → List< TNodeValue> -
Returns
rootplus all transitively dependent nodes (children, grandchildren, …), in topological order. Unmodifiable view. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recompute(
TNodeValue node) → Future< void> -
Recomputes the target state for
nodeand its transitive descendants. Call this when external state affecting the node's target changes (e.g.ownActivetoggled via a feature toggle). -
resolve(
) → Future< void> - Runs the initial cascade — computes a target for every node in topological order and transitions each one to it.
-
shutdown(
) → Future< void> -
Transitions every currently-active node to
disabledin reverse topological order, awaiting the visitor'sonDeactivatefor each. -
statusOf(
TNodeValue node) → GraphNodeStatus -
Current status of
nodein the cascade state machine. Returns GraphNodeStatus.disabled for unknown values. -
topologicalOrder(
) → List< TNodeValue> - Returns node values in topological order — parents before children. The returned view is unmodifiable and cached across calls.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited