pub struct Graph { /* private fields */ }Expand description
图(Graph)— 允许有环,循环保护由 GraphExecutor::max_steps 运行时熔断提供。
Implementations§
Source§impl Graph
impl Graph
pub fn name(&self) -> &str
pub fn node_names(&self) -> Vec<&str>
pub fn start_node(&self) -> &str
pub fn end_node(&self) -> &str
Sourcepub fn hash(&self) -> String
pub fn hash(&self) -> String
计算图结构指纹 hash。
用于 Checkpoint 恢复时校验图结构是否变更。 基于节点名和边定义生成简化的 hash 字符串。
pub fn edges_from(&self, from: &str) -> Vec<&Edge>
pub fn find_edge(&self, from: &str, to: &str) -> Option<&Edge>
Sourcepub fn find_fallback_edge(&self, from: &str) -> Option<String>
pub fn find_fallback_edge(&self, from: &str) -> Option<String>
查找指定节点的 fallback 边目标。
用于 Fallback 控制流:节点主动声明降级后,Executor 查找 fallback 边路由。
Sourcepub fn validate(&self) -> Result<(), TerminalError>
pub fn validate(&self) -> Result<(), TerminalError>
验证图结构(节点、边引用有效性)。
注意:不检测环 — 有环图是合法的,循环保护由 GraphExecutor::max_steps 提供。
Sourcepub fn analyze(&self) -> GraphDiagnostics
pub fn analyze(&self) -> GraphDiagnostics
完整图诊断分析。
检查以下维度并返回 GraphDiagnostics:
- 环检测 — 图中存在循环路径(Warning)
- Fallback 参与循环 — fallback 边在环内(Warning)
- 不可达路径 — 从 start 无法到达的节点(Info)
- End 节点出边 — end 节点定义了出边(Info)
与 build() 的关系:build() 只检查结构正确性;analyze() 检查风险性。
Sourcepub fn analyze_cycles(&self) -> CycleAnalysis
pub fn analyze_cycles(&self) -> CycleAnalysis
分析图中所有环,生成诊断信息。
@deprecated 使用 analyze() 替代。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Graph
impl !UnwindSafe for Graph
impl Freeze for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
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