Class GraphExecutor
Executes a graph by propagating data through connected nodes. Uses topological sorting for correct execution order. Optimized for incremental updates - only re-executes affected nodes. Thread-safe for concurrent access from multiple threads.
public sealed class GraphExecutor : IDisposable
- Inheritance
-
GraphExecutor
- Implements
- Inherited Members
Constructors
GraphExecutor(Graph)
Creates a new graph executor.
public GraphExecutor(Graph graph)
Parameters
graphGraphThe graph to execute.
Properties
Processors
Gets all registered processors.
public IReadOnlyDictionary<string, INodeProcessor> Processors { get; }
Property Value
Methods
BeginBatchUpdate()
Begins a batch update. Changes won't propagate until EndBatchUpdate is called. Use this when making multiple changes to prevent intermediate executions.
public void BeginBatchUpdate()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EndBatchUpdate()
Ends batch update and executes all dirty nodes.
public void EndBatchUpdate()
ExecuteAll()
Executes the entire graph in topological order.
public void ExecuteAll()
ExecuteFrom(string)
Executes only nodes affected by a change to the specified node. More efficient than ExecuteAll when only one input changed.
public void ExecuteFrom(string nodeId)
Parameters
nodeIdstringThe node that changed.
GetProcessor(string)
Gets a processor by node ID.
public INodeProcessor? GetProcessor(string nodeId)
Parameters
nodeIdstringThe node ID.
Returns
- INodeProcessor
The processor, or null if not found.
GetProcessor<T>(string)
Gets a typed processor by node ID.
public T? GetProcessor<T>(string nodeId) where T : class, INodeProcessor
Parameters
nodeIdstringThe node ID.
Returns
- T
The processor, or null if not found or wrong type.
Type Parameters
TThe processor type.
PropagateFromPort(string, string)
Propagates the current value from a source port to all connected target ports.
public void PropagateFromPort(string sourceNodeId, string sourcePortId)
Parameters
RegisterProcessor(INodeProcessor)
Registers a processor for a node.
public void RegisterProcessor(INodeProcessor processor)
Parameters
processorINodeProcessorThe processor to register.
UnregisterProcessor(string)
Unregisters a processor.
public bool UnregisterProcessor(string nodeId)
Parameters
nodeIdstringThe node ID to unregister.
Returns
- bool
True if the processor was found and removed.
Events
ExecutionCompleted
Event raised when execution completes.
public event EventHandler? ExecutionCompleted
Event Type
ExecutionStarted
Event raised when execution starts.
public event EventHandler? ExecutionStarted
Event Type
NodeProcessed
Event raised when a node is processed.
public event EventHandler<NodeProcessedEventArgs>? NodeProcessed