Skip to main content

write_edgelist

Function write_edgelist 

Source
pub fn write_edgelist<W: Write>(
    graph: &Graph,
    writer: &mut W,
) -> IgraphResult<()>
Expand description

Write a graph as an edge list.

Outputs one line per edge: "source target\n" using 0-based vertex IDs. Isolated vertices are not represented in the output.

ยงExamples

use rust_igraph::{Graph, write_edgelist};

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_edgelist(&g, &mut buf).unwrap();
let s = String::from_utf8(buf).unwrap();
assert_eq!(s, "0 1\n1 2\n");