pub fn write_pajek<W: Write>(
graph: &Graph,
labels: Option<&[String]>,
weights: Option<&[f64]>,
writer: &mut W,
) -> IgraphResult<()>Expand description
Write a graph in Pajek (.net) format.
Writes *Vertices section (with optional labels), then *Edges
(undirected) or *Arcs (directed) section with optional weights.
When labels is None, falls back to the "name" vertex attribute
if present. When weights is None, falls back to the "weight"
edge attribute if present.
ยงExamples
use rust_igraph::{Graph, write_pajek, AttributeValue};
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.set_vertex_attribute_all("name", vec![
AttributeValue::String("A".into()),
AttributeValue::String("B".into()),
AttributeValue::String("C".into()),
]).unwrap();
let mut buf = Vec::new();
write_pajek(&g, None, None, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("*Vertices 3"));
assert!(s.contains("\"A\""));
assert!(s.contains("*Edges"));