synaptic_graph/edge.rs
1use std::collections::HashMap;
2use std::sync::Arc;
3
4use crate::State;
5
6/// A fixed edge from source node to target node.
7#[derive(Debug, Clone)]
8pub struct Edge {
9 pub source: String,
10 pub target: String,
11}
12
13/// A routing function that inspects state and returns a target node name.
14pub type RouterFn<S> = Arc<dyn Fn(&S) -> String + Send + Sync>;
15
16/// A conditional edge from source node to a dynamically chosen target.
17pub struct ConditionalEdge<S: State> {
18 pub source: String,
19 pub router: RouterFn<S>,
20 /// Optional mapping of label → target node name, used for visualization.
21 pub path_map: Option<HashMap<String, String>>,
22}