GraphPropagationEngine
Propagates computed values through a VisuallyJS graph.
The engine treats each node or group as the unit of computation. A calculator is registered per
vertex type, reads upstream values through an EvaluationContext, and returns output terminal
values plus optional internal state for that vertex.
Output keys are terminal ids: use a port id for named ports, or DEFAULT_TERMINAL for edges
connected directly to the node/group body. During propagation, the engine maps those terminal ids
back to concrete graph vertices and writes propagated values to property on target vertices.
Calculator state is not propagated across edges. It is written to the owning node/group under
stateProperty, making it suitable for display data, validation results, summaries, or cached
derived values.
To integrate, define calculators keyed by node/group type, construct the engine with a
VisuallyJsModel, and read propagated values from vertices using property and computed state
from nodes/groups using stateProperty.
Type Parameters
ValueType
ValueType
StateType
StateType = unknown
Constructors
Constructor
new GraphPropagationEngine<
ValueType,StateType>(model,calculators,property,stateProperty):GraphPropagationEngine<ValueType,StateType>
Creates a propagation engine and binds it to model update events.
Edge additions/removals and data updates on connected vertices trigger recalculation on the next animation frame. Updates produced by the engine are applied in one model transaction.
Parameters
model
Model whose nodes, groups, ports, and edges should participate in propagation.
calculators
Record<string, Calculator<ValueType, StateType>>
Calculator functions keyed by node/group type.
property
string = "value"
Data property used for propagated vertex values. Defaults to "value".
stateProperty
string = "computed"
Data property used for computed node/group state. Defaults to "computed".
Returns
GraphPropagationEngine<ValueType, StateType>
Methods
calculate()
calculate(
knownValues?):CalculationResult<ValueType,StateType>
Runs propagation immediately and writes the result back to the model.
knownValues can seed the value cache for this run. Keys must be concrete vertex ids, such
as a node id or full port id. This is useful when an edited source value is already known and
should be used before the model has been fully re-read.
Parameters
knownValues?
Record<string, ValueType>
Returns
CalculationResult<ValueType, StateType>