flow_rs_core/layout/
mod.rs

1//! Layout algorithms for automatic node positioning
2
3use crate::error::Result;
4use crate::graph::Graph;
5
6/// Trait for layout algorithms
7pub trait LayoutAlgorithm<N, E> {
8    /// Name of the layout algorithm
9    fn name(&self) -> &str;
10
11    /// Apply the layout to the graph
12    fn apply(&mut self, graph: &mut Graph<N, E>) -> Result<()>;
13
14    /// Check if the algorithm is running
15    fn is_running(&self) -> bool {
16        false
17    }
18
19    /// Stop the algorithm if it's running
20    fn stop(&mut self) -> Result<()> {
21        Ok(())
22    }
23
24    /// Get the progress (0.0 to 1.0)
25    fn progress(&self) -> f64 {
26        1.0
27    }
28
29    /// Check if the algorithm can be interrupted
30    fn can_interrupt(&self) -> bool {
31        false
32    }
33}
34
35// Re-export all algorithms
36pub mod algorithms;
37pub mod utils;
38
39pub use algorithms::*;
40pub use utils::LayoutUtils;
41
42#[cfg(test)]
43mod tests;