Skip to main content

LazyAdjList

Struct LazyAdjList 

Source
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>

Source

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.

Source

pub fn is_empty(&self) -> bool

Whether the underlying graph has no vertices.

Source

pub fn graph(&self) -> &'g Graph

The graph this lazy list reads from.

Source

pub fn mode(&self) -> NeighborMode

The effective neighbor mode (always NeighborMode::All for undirected graphs).

Source

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.

Source

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).

Source

pub fn get_mut(&mut self, v: VertexId) -> Result<&mut VectorInt>

The neighbors of vertex v as a mutable VectorInt, computed on first access.

Modifying it changes only the cached copy, never the graph.

§Errors

As get.

Source

pub fn to_vecs(&mut self) -> Result<Vec<Vec<igraph_int_t>>>

Computes (if needed) all the lists and copies them into nested Rust vectors.

§Errors

As get.

Source

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>

Source

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.

Source

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.

Source

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.)

Trait Implementations§

Source§

impl Debug for LazyAdjList<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for LazyAdjList<'_>

Source§

fn drop(&mut self)

Frees the cached lists with igraph_lazy_adjlist_destroy.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'g> !Send for LazyAdjList<'g>

§

impl<'g> !Sync for LazyAdjList<'g>

§

impl<'g> Freeze for LazyAdjList<'g>

§

impl<'g> RefUnwindSafe for LazyAdjList<'g>

§

impl<'g> Unpin for LazyAdjList<'g>

§

impl<'g> UnsafeUnpin for LazyAdjList<'g>

§

impl<'g> UnwindSafe for LazyAdjList<'g>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.