Skip to main content

write_leda

Function write_leda 

Source
pub fn write_leda<W: Write>(
    graph: &Graph,
    vertex_labels: Option<&[String]>,
    edge_weights: Option<&[f64]>,
    writer: &mut W,
) -> IgraphResult<()>
Expand description

Write a graph in LEDA native graph format.

Vertex labels are written as string attributes if provided. Edge weights are written as double attributes if provided. The reversal field for edges is always 0 (no reverse edge pointer).

ยงExamples

use rust_igraph::{Graph, write_leda};

let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();

let labels = vec!["A".to_string(), "B".to_string(), "C".to_string()];
let mut buf = Vec::new();
write_leda(&g, Some(&labels), None, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("LEDA.GRAPH"));
assert!(s.contains("|{A}|"));