Skip to main content

write_dot

Function write_dot 

Source
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.

§Examples

use rust_igraph::{Graph, write_dot};

let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).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("--"));