pub fn write_dot<W: Write>(
graph: &Graph,
labels: Option<&[String]>,
writer: &mut W,
) -> IgraphResult<()>Expand description
Write a graph in DOT (Graphviz) format.
If labels is provided, uses them as vertex labels; otherwise uses
numeric ids. Isolated vertices are listed explicitly. Vertex and edge
attributes stored on the Graph are emitted as DOT attribute blocks
[key=value, ...].
ยงExamples
use rust_igraph::{Graph, write_dot, AttributeValue};
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.set_vertex_attribute("color", 0, AttributeValue::String("red".into())).unwrap();
g.set_edge_attribute("weight", 0, AttributeValue::Numeric(1.5)).unwrap();
let mut buf = Vec::new();
write_dot(&g, None, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("graph {"));
assert!(s.contains("[color=\"red\"]"));
assert!(s.contains("[weight=1.5]"));