pub struct Graph {
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
pub training_strategy: Option<TrainingStrategy>,
}Expand description
A directed graph of computational nodes.
Fields§
§nodes: Vec<Node>§edges: Vec<Edge>§training_strategy: Option<TrainingStrategy>Training strategy for distributed execution. Inherited by subgraphs unless overridden.
Implementations§
Source§impl Graph
impl Graph
pub fn new() -> Self
Sourcepub fn with_strategy(self, strategy: TrainingStrategy) -> Self
pub fn with_strategy(self, strategy: TrainingStrategy) -> Self
Set the training strategy for this graph.
Sourcepub fn set_strategy(&mut self, strategy: TrainingStrategy)
pub fn set_strategy(&mut self, strategy: TrainingStrategy)
Set the training strategy (mutable).
Sourcepub fn effective_strategy(&self) -> &TrainingStrategy
pub fn effective_strategy(&self) -> &TrainingStrategy
Get the effective training strategy (defaults to Local).
pub fn add_node(&mut self, node: Node)
Sourcepub fn add_filter(&mut self, filter_name: impl Into<String>) -> &str
pub fn add_filter(&mut self, filter_name: impl Into<String>) -> &str
Add a filter node using the filter name as the node id. If a node with that name already exists, appends a suffix.
pub fn add_edge(&mut self, edge: Edge)
Sourcepub fn connect(&mut self, source: impl Into<String>, target: impl Into<String>)
pub fn connect(&mut self, source: impl Into<String>, target: impl Into<String>)
Connect two nodes with a data edge (auto-generates edge id).
Sourcepub fn predecessors(&self, node_id: &str) -> Vec<&str>
pub fn predecessors(&self, node_id: &str) -> Vec<&str>
Get predecessors of a node (nodes with edges pointing to it).
Sourcepub fn successors(&self, node_id: &str) -> Vec<&str>
pub fn successors(&self, node_id: &str) -> Vec<&str>
Get successors of a node (nodes it points to).
Sourcepub fn topological_sort(&self) -> Result<Vec<&str>>
pub fn topological_sort(&self) -> Result<Vec<&str>>
Topological sort using Kahn’s algorithm. Returns Err if the graph contains a cycle.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Graph
impl<'de> Deserialize<'de> for Graph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe 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