pub struct LazyAdjList<'g> { /* private fields */ }Expand description
Lazy adjacency list (igraph_lazy_adjlist_t) borrowing a graph: the
neighbors of each vertex are queried on first access and cached.
Create it with Graph::lazy_adjlist_init or LazyAdjList::new. Since
queries fill the cache, access needs &mut self.
Implementations§
Source§impl<'g> LazyAdjList<'g>
impl<'g> LazyAdjList<'g>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of vertices of the lazy adjacency list, i.e. of the graph (igraph_lazy_adjlist_size).
Binds igraph_lazy_adjlist_size.
Sourcepub fn mode(&self) -> NeighborMode
pub fn mode(&self) -> NeighborMode
The effective neighbor mode (always NeighborMode::All for
undirected graphs).
Sourcepub fn has(&self, v: VertexId) -> bool
pub fn has(&self, v: VertexId) -> bool
Whether the neighbors of vertex v were already computed and cached.
Returns false for out-of-range vertices. Time complexity: O(1).
Binds the igraph_lazy_adjlist_has macro.
Sourcepub fn get(&mut self, v: VertexId) -> Result<&[igraph_int_t]>
pub fn get(&mut self, v: VertexId) -> Result<&[igraph_int_t]>
The neighbors of vertex v, computed on the first call and cached afterwards.
The returned slice borrows the lazy list mutably, so copy it
(.to_vec()) if you need to query other vertices while using
it. Time complexity: O(d) on the first call for a vertex of
degree d, O(1) afterwards.
Binds the igraph_lazy_adjlist_get macro.
§Errors
ErrorKind::InvalidVertexId if v is out of range, or an
igraph error if the list cannot be computed (out of memory).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Forgets all the cached lists (igraph_lazy_adjlist_clear); they will be recomputed on demand.
Any edits made through get_mut are lost.
Binds igraph_lazy_adjlist_clear.
Source§impl<'g> LazyAdjList<'g>
impl<'g> LazyAdjList<'g>
Sourcepub fn new(
graph: &'g Graph,
mode: NeighborMode,
loops: Loops,
multiple: bool,
) -> Result<Self>
pub fn new( graph: &'g Graph, mode: NeighborMode, loops: Loops, multiple: bool, ) -> Result<Self>
Lazy adjacency list of graph: same as Graph::lazy_adjlist_init.
Sourcepub fn loops(&self) -> Loops
pub fn loops(&self) -> Loops
The effective loop handling.
This is the loops argument given at creation, unless igraph already
knew that the graph has no self-loops: then it reports
Loops::Twice (mode All) or Loops::Once (mode In/Out),
which avoids a useless filtering pass and yields the same lists.
Sourcepub fn multiple(&self) -> bool
pub fn multiple(&self) -> bool
Whether multi-edges are kept.
This is the multiple argument given at creation, except for an
Out or In list of a directed graph that igraph already knew to
have no multi-edges: then it is true, since there is nothing to
collapse. (Lists gathering neighbors in both directions are always
collapsed as requested; see Graph::adjlist_init for the igraph
1.0.0 and 1.0.1 bug this works around.)