pub fn write_gml<W: Write>(graph: &Graph, writer: &mut W) -> IgraphResult<()>Expand description
Write a graph in GML format, including attributes.
Produces a valid GML file with graph [ directed 0/1 node [ id N ... ] ... edge [ source N target N ... ] ... ]. Graph, vertex, and edge
attributes are written as additional key-value pairs.
ยงExamples
use rust_igraph::{Graph, write_gml, read_gml, AttributeValue};
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.set_vertex_attribute("label", 0, "A".into()).unwrap();
g.set_edge_attribute("weight", 0, 2.5.into()).unwrap();
let mut buf = Vec::new();
write_gml(&g, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("directed 1"));
assert!(s.contains("label \"A\""));
assert!(s.contains("weight 2.5"));
// Round-trip
let g2 = read_gml(s.as_bytes()).unwrap();
assert_eq!(g2.vcount(), 3);
assert_eq!(g2.ecount(), 2);
assert!(g2.is_directed());