Crate graph_sp

Crate graph_sp 

Source
Expand description

§graph-sp

A pure Rust graph executor supporting implicit node connections, branching, and config sweeps.

§Features

  • Implicit Node Connections: Nodes are automatically connected based on execution order
  • Branching: Create parallel execution paths with .branch()
  • Config Sweeps: Use .variant() to create configuration variations
  • DAG Optimization: Automatic inspection and optimization of execution paths
  • Mermaid Visualization: Generate diagrams with to_mermaid()

§Example

use graph_sp::Graph;
use std::collections::HashMap;

fn data_source(_: &HashMap<String, String>) -> HashMap<String, String> {
    let mut result = HashMap::new();
    result.insert("output".to_string(), "Hello, World!".to_string());
    result
}

fn processor(inputs: &HashMap<String, String>) -> HashMap<String, String> {
    let mut result = HashMap::new();
    if let Some(data) = inputs.get("input") {
        result.insert("output".to_string(), data.to_uppercase());
    }
    result
}

let mut graph = Graph::new();
graph.add(data_source, Some("Source"), None, Some(vec!["output"]));
graph.add(processor, Some("Processor"), Some(vec!["input"]), Some(vec!["output"]));

let dag = graph.build();

Structs§

Dag
Directed Acyclic Graph representing the optimized execution plan
ExecutionResult
Execution result that tracks outputs per node and per branch
Generator
Helper struct for custom generator functions
Geomspace
Helper struct for geometric progression
Graph
Graph builder for constructing graphs with implicit node connections
Linspace
Helper struct for linearly spaced values
Logspace
Helper struct for logarithmically spaced values

Traits§

IntoVariantValues
Trait for types that can be converted into variant values

Type Aliases§

ExecutionContext
Execution context for storing variable values during graph execution
NodeFunction
Type alias for node execution functions Takes broadcast variables and variant parameters as input, returns output variables
NodeId
Unique identifier for a node