Skip to main content

read_graphdb

Function read_graphdb 

Source
pub fn read_graphdb<R: Read>(input: R, directed: bool) -> IgraphResult<Graph>
Expand description

Read a graph from GraphDB binary format.

The format stores adjacency lists in packed little-endian 16-bit words. Creates a directed or undirected graph depending on the directed parameter.

ยงExamples

use rust_igraph::read_graphdb;

// 2 vertices; vertex 0 has 1 edge to vertex 1; vertex 1 has 0 edges
let data: Vec<u8> = vec![
    2, 0,  // n_vertices = 2
    1, 0,  // vertex 0: 1 neighbor
    1, 0,  // neighbor: vertex 1
    0, 0,  // vertex 1: 0 neighbors
];
let g = read_graphdb(&data[..], true).unwrap();
assert_eq!(g.vcount(), 2);
assert_eq!(g.ecount(), 1);
assert!(g.is_directed());