Expand description
Owned typed lists (igraph_typed_list_pmt.h): VectorIntList,
VectorList, MatrixList, GraphList and BitsetList.
igraph returns collections of vectors (paths, cliques, components, …)
and of graphs (decompositions, …) through these list types. Each list
owns its items: it frees them on Drop, can be indexed (list[i]),
iterated by reference, and converted into standard Rust collections.
The safe wrappers of the crate usually convert them for you, e.g.
Graph::maximal_cliques returns a
Vec<Vec<i64>> and Graph::decompose a
Vec<Graph>; the list types matter when calling raw FFI functions or
when a wrapper takes a list as input.
use igraph::prelude::*;
let list = VectorIntList::from_iter([vec![0, 1], vec![2, 3, 4]]);
assert_eq!(list.len(), 2);
assert_eq!(list[1].as_slice(), &[2, 3, 4]);
let nested: Vec<Vec<i64>> = list.to_vecs();
assert_eq!(nested, vec![vec![0, 1], vec![2, 3, 4]]);Every list supports push, pop, insert, remove, swap_remove,
replace, swap, reverse, permute, truncate, clear,
sort_by/sort_by_key, push_copy, reserve/capacity, mutable
indexing and iteration. Lists of vectors can also be sorted and
deduplicated with igraph’s own comparators:
use igraph::prelude::*;
let mut cliques = VectorIntList::from_iter([vec![2, 3], vec![0, 1, 2], vec![2, 3], vec![0, 1]]);
cliques.sort(); // lexicographic, a prefix first
cliques.dedup();
assert_eq!(cliques.to_vecs(), vec![vec![0, 1], vec![0, 1, 2], vec![2, 3]]);
cliques.sort_by_key(|c| std::cmp::Reverse(c.len()));
assert_eq!(cliques[0], vec![0, 1, 2]);Type Aliases§
- Bitset
List - Owned list of bitsets (
igraph_bitset_list_t), seecrate::bitset. - Graph
List - Owned list of graphs (
igraph_graph_list_t). - Matrix
List - Owned list of real matrices (
igraph_matrix_list_t). - Vector
IntList - Owned list of integer vectors (
igraph_vector_int_list_t). - Vector
List - Owned list of real vectors (
igraph_vector_list_t).