use std::env;
use graphplot::{Edge, Layout, Multigraph, Node, PlotConfig};
fn main() {
let mut graph = Multigraph::new();
for (from, to) in [
("A", "B"),
("A", "C"),
("A", "D"),
("B", "E"),
("B", "C"),
("C", "E"),
("C", "F"),
("G", "G"),
("G", "H"),
("G", "H"),
("H", "G"),
] {
let from_id = graph.add_node(Node::from(from), false);
let to_id = graph.add_node(Node::from(to), false);
graph.add_edge(
Edge::from(from_id, to_id).label(format!("{from} -> {to}")),
true,
);
}
graph.highlight_edges([3, 4]);
graph.highlight_nodes([1, 2, 4]);
let config = PlotConfig::default().layout(Layout::Radial);
let api_key = env::var("GP_API_KEY").expect("No Graphplot API env variable");
graph
.save("graph.svg", api_key, Some(config))
.expect("Error plotting with Graphplot API")
}