pub fn write_lgl<W: Write>(
graph: &Graph,
names: Option<&[String]>,
weights: Option<&[f64]>,
writer: &mut W,
) -> IgraphResult<()>Expand description
Write a graph in LGL format.
Each vertex is written as a hub (# name) followed by its neighbours.
If names is provided, uses them as vertex labels; otherwise uses
numeric ids. If weights is provided (one per edge), appends the weight.
To avoid duplicate edges in the undirected representation, each edge is emitted only once: under the endpoint with the smaller index.
ยงExamples
use rust_igraph::{Graph, write_lgl};
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
let names = vec!["A".to_string(), "B".to_string(), "C".to_string()];
let mut buf = Vec::new();
write_lgl(&g, Some(&names), None, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("# A"));
assert!(s.contains("B"));
assert!(s.contains("C"));