pub struct StateGraph<S: State> { /* private fields */ }Expand description
Builder for constructing a state graph.
Implementations§
Source§impl<S: State> StateGraph<S>
impl<S: State> StateGraph<S>
pub fn new() -> Self
Sourcepub fn add_node(
self,
name: impl Into<String>,
node: impl Node<S> + 'static,
) -> Self
pub fn add_node( self, name: impl Into<String>, node: impl Node<S> + 'static, ) -> Self
Add a named node to the graph.
Sourcepub fn add_deferred_node(
self,
name: impl Into<String>,
node: impl Node<S> + 'static,
) -> Self
pub fn add_deferred_node( self, name: impl Into<String>, node: impl Node<S> + 'static, ) -> Self
Add a deferred node that waits until ALL incoming edges have been
traversed before executing. Useful for fan-in aggregation after
parallel fan-out with Send.
Sourcepub fn add_node_with_cache(
self,
name: impl Into<String>,
node: impl Node<S> + 'static,
cache: CachePolicy,
) -> Self
pub fn add_node_with_cache( self, name: impl Into<String>, node: impl Node<S> + 'static, cache: CachePolicy, ) -> Self
Add a named node with caching. Results are cached based on a hash of the serialized input state for the duration of the TTL.
Sourcepub fn add_edge(
self,
source: impl Into<String>,
target: impl Into<String>,
) -> Self
pub fn add_edge( self, source: impl Into<String>, target: impl Into<String>, ) -> Self
Add a fixed edge from source to target.
Sourcepub fn add_conditional_edges(
self,
source: impl Into<String>,
router: impl Fn(&S) -> String + Send + Sync + 'static,
) -> Self
pub fn add_conditional_edges( self, source: impl Into<String>, router: impl Fn(&S) -> String + Send + Sync + 'static, ) -> Self
Add a conditional edge with a routing function.
Sourcepub fn add_conditional_edges_with_path_map(
self,
source: impl Into<String>,
router: impl Fn(&S) -> String + Send + Sync + 'static,
path_map: HashMap<String, String>,
) -> Self
pub fn add_conditional_edges_with_path_map( self, source: impl Into<String>, router: impl Fn(&S) -> String + Send + Sync + 'static, path_map: HashMap<String, String>, ) -> Self
Add a conditional edge with a routing function and a path map for visualization.
Sourcepub fn set_entry_point(self, name: impl Into<String>) -> Self
pub fn set_entry_point(self, name: impl Into<String>) -> Self
Set the entry point node for graph execution.
Sourcepub fn interrupt_before(self, nodes: Vec<String>) -> Self
pub fn interrupt_before(self, nodes: Vec<String>) -> Self
Mark nodes that should interrupt BEFORE execution (human-in-the-loop).
Sourcepub fn interrupt_after(self, nodes: Vec<String>) -> Self
pub fn interrupt_after(self, nodes: Vec<String>) -> Self
Mark nodes that should interrupt AFTER execution (human-in-the-loop).
Sourcepub fn compile(self) -> Result<CompiledGraph<S>, SynapticError>
pub fn compile(self) -> Result<CompiledGraph<S>, SynapticError>
Compile the graph into an executable CompiledGraph.