use cpnets::prelude::*; use cpnets::state_graph::StateGraph; use std::error::Error; fn main() -> Result<(), Box> { let mut net = Net::new("traffic_light"); net.add_place(Place::new("green").with_capacity(1))?; net.add_place(Place::new("yellow").with_capacity(1))?; net.add_place(Place::new("red").with_capacity(1))?; net.add_transition(Transition::new("T0"))?; net.add_transition(Transition::new("T1"))?; net.add_transition(Transition::new("T2"))?; net.add_transition(Transition::new("T3"))?; net.add_arcs(arcs! { "green" => "T0"; "x", "T0" => "yellow"; expression!("x", &["x"]), "yellow" => "T1"; "x", "T1" => "red"; expression!("x", &["x"]), "red" => "T2"; "x", "T2" => "yellow"; expression!("x", &["x"]), "T2" => "red"; expression!("x", &["x"]), "yellow" => "T3"; "x", "red" => "T3"; "y", "T3" => "green"; expression!("x", &["x"]), })?; let marking = net.empty_marking().with("red", [token!("\"on\"")])?; let state_graph = StateGraph::init(net).compute(marking)?; state_graph.dump_dot(); Ok(()) }