graph_sp/lib.rs
1//! # graph-sp: A Comprehensive Rust-based DAG Execution Engine
2//!
3//! graph-sp is a high-performance, parallel DAG (Directed Acyclic Graph) execution engine
4//! with Python bindings. It provides true parallelization, flawless graph inspection,
5//! and port routing optimization.
6//!
7//! ## Features
8//!
9//! - **Port-based Architecture**: Nodes communicate through strongly-typed ports
10//! - **Parallel Execution**: Automatic parallelization of independent nodes using tokio
11//! - **Graph Inspection**: Comprehensive analysis and visualization tools
12//! - **Cycle Detection**: Built-in DAG validation
13//! - **Python Bindings**: Easy-to-use Python API via PyO3
14//!
15//! ## Core Components
16//!
17//! - `core`: Fundamental data structures (Graph, Node, Port, PortData)
18//! - `executor`: Parallel execution engine
19//! - `inspector`: Graph analysis and optimization tools
20//! - `python`: Python bindings (optional, enabled with "python" feature)
21//!
22//! ## Example
23//!
24//! ```rust
25//! use graph_sp::core::{Graph, Node, NodeConfig, Port, PortData};
26//! use graph_sp::executor::Executor;
27//! use std::collections::HashMap;
28//! use std::sync::Arc;
29//!
30//! #[tokio::main]
31//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
32//! // Create a graph
33//! let mut graph = Graph::new();
34//!
35//! // Define a simple node that doubles its input
36//! let config = NodeConfig::new(
37//! "doubler",
38//! "Doubler Node",
39//! vec![Port::new("input", "Input Value")],
40//! vec![Port::new("output", "Output Value")],
41//! Arc::new(|inputs: &HashMap<String, PortData>| {
42//! let mut outputs = HashMap::new();
43//! if let Some(PortData::Int(val)) = inputs.get("input") {
44//! outputs.insert("output".to_string(), PortData::Int(val * 2));
45//! }
46//! Ok(outputs)
47//! }),
48//! );
49//!
50//! // Add node to graph
51//! let mut node = Node::new(config);
52//! node.set_input("input", PortData::Int(21));
53//! graph.add(node)?;
54//!
55//! // Execute the graph
56//! let executor = Executor::new();
57//! let result = executor.execute(&mut graph).await?;
58//!
59//! // Get the result
60//! if let Some(PortData::Int(val)) = result.get_output("doubler", "output") {
61//! println!("Result: {}", val); // Output: 42
62//! }
63//!
64//! Ok(())
65//! }
66//! ```
67
68pub mod core;
69pub mod executor;
70pub mod inspector;
71
72#[cfg(feature = "python")]
73pub mod python;
74
75// Re-export commonly used types
76pub use core::{Edge, Graph, GraphData, GraphError, Node, NodeConfig, Port, PortData, Result};
77pub use executor::{ExecutionResult, Executor};
78pub use inspector::{GraphAnalysis, Inspector, Optimization, OptimizationType};