use knotrel_core::{EngineConfig, LifecycleGraph};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
println!("=== Knotrel Node and Edge Lifecycle Example ===\n");
let mut graph = LifecycleGraph::new(EngineConfig::CompactBfs)?;
graph.link(1, 2)?;
graph.link(2, 3)?;
graph.link(2, 4)?;
graph.set_node_active(2, false)?;
println!(
"node 2 inactive: connected(1, 3) = {}",
graph.connected(1, 3)?
);
graph.set_edge_enabled(2, 4, false)?;
graph.set_node_active(2, true)?;
println!(
"node 2 active again: connected(1, 3) = {}",
graph.connected(1, 3)?
);
println!(
"edge 2-4 stayed disabled: {:?}, connected(1, 4) = {}",
graph.edge_state(2, 4),
graph.connected(1, 4)?
);
println!(
"counts: {} registered nodes, {} active; {} registered edges, {} enabled, {} effective",
graph.node_count(),
graph.active_node_count(),
graph.edge_count(),
graph.enabled_edge_count(),
graph.effective_edge_count()
);
graph.remove_node(2);
graph.add_node(2)?;
println!(
"node 2 removed and re-created: edge 1-2 = {:?}, connected(1, 2) = {}",
graph.edge_state(1, 2),
graph.connected(1, 2)?
);
assert_eq!(graph.edge_count(), 0);
Ok(())
}