Skip to main content

read_lgl

Function read_lgl 

Source
pub fn read_lgl<R: Read>(input: R) -> IgraphResult<LglGraph>
Expand description

Read a graph from LGL (.lgl) format.

Lines starting with # introduce a hub vertex. Subsequent lines (until the next hub or EOF) list neighbours, optionally followed by a weight. Empty lines are skipped.

ยงExamples

use rust_igraph::read_lgl;

let lgl = b"# Alice\nBob 1.0\nCarol\n# Bob\nCarol 2.5\n";
let result = read_lgl(&lgl[..]).unwrap();
assert_eq!(result.graph.vcount(), 3);
assert_eq!(result.graph.ecount(), 3);
assert_eq!(result.names, vec!["Alice", "Bob", "Carol"]);