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_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.
The path_map maps labels to target node names, enabling graph visualization
tools to show possible routing targets for conditional edges.
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>, SynapseError>
pub fn compile(self) -> Result<CompiledGraph<S>, SynapseError>
Compile the graph into an executable CompiledGraph.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for StateGraph<S>
impl<S> !RefUnwindSafe for StateGraph<S>
impl<S> Send for StateGraph<S>
impl<S> Sync for StateGraph<S>
impl<S> Unpin for StateGraph<S>
impl<S> UnsafeUnpin for StateGraph<S>
impl<S> !UnwindSafe for StateGraph<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more