use graphviz::{Graph, Context};
use graphviz::layout::{apply_layout, Engine};
use graphviz::render::{render_to_file, Format};
use graphviz::attr::AttributeContainer;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let context = Context::new()?;
let mut graph = Graph::new("basic_graph", true)?;
let node_a = graph.add_node("A")?;
let node_b = graph.add_node("B")?;
let node_c = graph.add_node("C")?;
graph.add_edge(&node_a, &node_b, None)?;
graph.add_edge(&node_b, &node_c, None)?;
graph.add_edge(&node_c, &node_a, None)?;
graph.set_attribute("rankdir", "LR")?;
node_a.set_attribute("shape", "box")?;
node_b.set_attribute("style", "filled")?;
node_b.set_attribute("fillcolor", "lightblue")?;
apply_layout(&context, &mut graph, Engine::Dot)?;
render_to_file(&context, &graph, Format::Svg, "basic_graph.svg")?;
Ok(())
}