Skip to main content

LabeledVecGraph

Struct LabeledVecGraph 

Source
pub struct LabeledVecGraph<L: Clone + 'static> { /* private fields */ }
Expand description

A mutable LabeledRandomAccessGraph implementation based on a vector of vectors.

This implementation is faster and uses less resources than a LabeledBTreeGraph, but it is less flexible as arcs can be added only in increasing successor order.

This struct can be serialized with ε-serde. By setting the feature serde, this struct can be serialized using serde, too.

Implementations§

Source§

impl<L: Clone + 'static> LabeledVecGraph<L>

Source

pub fn new() -> Self

Creates a new empty graph.

Source

pub fn empty(n: usize) -> Self

Creates a new empty graph with n nodes.

Source

pub fn add_node(&mut self, node: usize) -> bool

Add an isolated node to the graph and return true if it is a new node.

Source

pub fn add_arc(&mut self, u: usize, v: usize, l: L)

Add an arc to the graph.

New arcs must be added in increasing successor order, or this method will panic.

§Panics

This method will panic:

  • if one of the given nodes is greater or equal than the number of nodes in the graph;
  • if the successor is lesser than or equal to the current last successor of the source node.
Source

pub fn add_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)>,

Add nodes and successors from an IntoLender yielding a NodeLabelsLender.

If the lender is sorted, consider using add_sorted_lender, as it does not need to sort the output of the lender.

Source

pub fn from_lender<I: IntoLender>(iter_nodes: I) -> Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)>,

Creates a new graph from an IntoLender yielding a NodeLabelsLender.

If the lender is sorted, consider using from_sorted_lender, as it does not need to sort the output of the lender.

Source

pub fn add_sorted_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender, for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator,

Add nodes and successors from an IntoLender yielding a sorted NodeLabelsLender.

This method is faster than add_lender as it does not need to sort the output of the lender.

Source

pub fn from_sorted_lender<I: IntoLender>(iter_nodes: I) -> Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender, for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator,

Creates a new graph from a sorted IntoLender yielding a NodeLabelsLender.

This method is faster than from_lender as it does not need to sort the output of the lender.

Source

pub fn add_exact_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender, for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator + ExactSizeIterator,

Add nodes and successors from an IntoLender yielding a sorted NodeLabelsLender whose successors implement ExactSizeIterator.

This method has a better memory behavior than add_sorted_lender as it can allocate the right amount of memory for each node at once.

Source

pub fn from_exact_lender<I: IntoLender>(iter_nodes: I) -> Self
where I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender, for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator + ExactSizeIterator,

Creates a new graph from a sorted IntoLender yielding a NodeLabelsLender whose successors implement ExactSizeIterator.

This method has a better memory behavior than from_sorted_lender as it can allocate the right amount of memory for each node at once.

Source

pub fn add_arcs(&mut self, arcs: impl IntoIterator<Item = ((usize, usize), L)>)

Add labeled arcs from an IntoIterator, adding new nodes as needed.

The items must be labeled pairs of the form ((usize, usize), l) specifying an arc and its label.

Source

pub fn from_arcs(arcs: impl IntoIterator<Item = ((usize, usize), L)>) -> Self

Creates a new graph from an IntoIterator.

The items must be labeled pairs of the form ((usize, usize), l) specifying an arc and its label.

Source

pub fn shrink_to_fit(&mut self)

Shrink the capacity of the graph to fit its current size.

Trait Implementations§

Source§

impl<L: Clone + 'static> AlignHash for LabeledVecGraph<L>
where u64: SerInner<SerType: AlignHash>, Vec<Vec<LabeledArc<L>>>: SerInner<SerType: AlignHash>,

Source§

fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)

Accumulates alignment information in hasher assuming to be positioned at offset_of.
Source§

fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)

Calls AlignHash::align_hash on a value.
Source§

impl<L: Clone + Clone + 'static> Clone for LabeledVecGraph<L>

Source§

fn clone(&self) -> LabeledVecGraph<L>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Clone + 'static> CopyType for LabeledVecGraph<L>

Source§

impl<L: Debug + Clone + 'static> Debug for LabeledVecGraph<L>

Source§

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

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

impl<L: Clone + 'static> Default for LabeledVecGraph<L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<L: Clone + 'static> DeserInner for LabeledVecGraph<L>

Source§

type DeserType<'__epserde_desertype> = LabeledVecGraph<L>

The deserialization type associated with this type. It can be retrieved conveniently with the alias DeserType.
Source§

fn __check_covariance<'__long: '__short, '__short>( proof: CovariantProof<Self::DeserType<'__long>>, ) -> CovariantProof<Self::DeserType<'__short>>

Compile-time covariance check for DeserType. Read more
Source§

unsafe fn _deser_full_inner( backend: &mut impl ReadWithPos, ) -> Result<Self, Error>

Safety Read more
Source§

unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>( backend: &mut SliceWithPos<'deser_eps_inner_lifetime>, ) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>

Safety Read more
Source§

impl From<LabeledVecGraph<()>> for VecGraph

Source§

fn from(g: LabeledVecGraph<()>) -> Self

Converts to this type from the input type.
Source§

impl<'a, L: Clone + 'static> IntoLender for &'a LabeledVecGraph<L>

Convenience implementation that makes it possible to iterate over the graph using the for_ macro (see the crate documentation).

Source§

type Lender = <LabeledVecGraph<L> as SequentialLabeling>::Lender<'a>

The lender type that this type converts into.
Source§

fn into_lender(self) -> Self::Lender

Converts this type into a Lender.
Source§

impl<L: Clone + 'static> LabeledRandomAccessGraph<L> for LabeledVecGraph<L>

Source§

fn successors( &self, node_id: usize, ) -> <Self as RandomAccessLabeling>::Labels<'_>

Returns pairs given by successors of a node and their labels. Read more
Source§

fn has_arc(&self, src: usize, dst: usize) -> bool

Returns whether there is an arc going from src_node_id to dst_node_id. Read more
Source§

impl<L: PartialEq + Clone + 'static> PartialEq for LabeledVecGraph<L>

Source§

fn eq(&self, other: &LabeledVecGraph<L>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<L: Clone + 'static> RandomAccessLabeling for LabeledVecGraph<L>

Source§

type Labels<'succ> = AssumeSortedIterator<Map<Cloned<Iter<'succ, LabeledArc<L>>>, fn(LabeledArc<L>) -> (usize, L)>>

The type of the iterator over the labels of a node returned by labels.
Source§

fn num_arcs(&self) -> u64

Returns the number of arcs in the graph.
Source§

fn outdegree(&self, node: usize) -> usize

Returns the number of labels associated with a node.
Source§

fn labels(&self, node: usize) -> <Self as RandomAccessLabeling>::Labels<'_>

Returns the labels associated with a node.
Source§

impl<L: Clone + 'static> SequentialLabeling for LabeledVecGraph<L>

Source§

type Label = (usize, L)

Source§

type Lender<'a> = LenderImpl<'a, LabeledVecGraph<L>> where Self: 'a

The type of Lender over the successors of a node returned by iter.
Source§

fn num_nodes(&self) -> usize

Returns the number of nodes in the graph.
Source§

fn num_arcs_hint(&self) -> Option<u64>

Returns the number of arcs in the graph, if available.
Source§

fn iter_from(&self, from: usize) -> Self::Lender<'_>

Returns an iterator over the labeling starting at from (included). Read more
Source§

fn iter(&self) -> Self::Lender<'_>

Returns an iterator over the labeling. Read more
Source§

fn build_dcf(&self) -> DCF

Builds the degree cumulative function for this labeling. Read more
Source§

fn par_node_apply<A: Default + Send, F: Fn(Range<usize>) -> A + Sync, R: Fn(A, A) -> A + Sync>( &self, func: F, fold: R, granularity: Granularity, pl: &mut impl ConcurrentProgressLog, ) -> A

Applies func to each chunk of nodes of size node_granularity in parallel, and folds the results using fold. Read more
Source§

fn par_apply<F: Fn(Range<usize>) -> A + Sync, A: Default + Send, R: Fn(A, A) -> A + Sync, D: for<'a> Succ<Input = usize, Output<'a> = usize>>( &self, func: F, fold: R, granularity: Granularity, deg_cumul: &D, pl: &mut impl ConcurrentProgressLog, ) -> A

Applies func to each chunk of nodes containing approximately arc_granularity arcs in parallel and folds the results using fold. Read more
Source§

impl<L: Clone + 'static> SerInner for LabeledVecGraph<L>

Source§

const IS_ZERO_COPY: bool

Inner constant used by the derive macros to keep track recursively of whether the type satisfies the conditions for being zero-copy. It is checked at runtime against the trait implemented by the type, and if a ZeroCopy type has this constant set to false serialization will panic.
Source§

type SerType = LabeledVecGraph<L>

This is the type that will be written in the header of the file, and thus the type that will be deserialized. In most cases it is Self, but in some cases, as for references to slices, it is customized.
Source§

unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>

Serializes this structure using the given backend. Read more
Source§

impl<L: Clone + Sync> SplitLabeling for LabeledVecGraph<L>

Source§

type SplitLender<'a> = Take<<LabeledVecGraph<L> as SequentialLabeling>::Lender<'a>> where Self: 'a

Source§

type IntoIterator<'a> = Iter<'a, LabeledVecGraph<L>> where Self: 'a

Source§

fn split_iter(&self, how_many: usize) -> Self::IntoIterator<'_>

Source§

impl<L: Clone + 'static> TypeHash for LabeledVecGraph<L>
where u64: SerInner<SerType: TypeHash>, Vec<Vec<LabeledArc<L>>>: SerInner<SerType: TypeHash>,

Source§

fn type_hash(hasher: &mut impl Hasher)

Accumulates type information in hasher.
Source§

fn type_hash_val(&self, hasher: &mut impl Hasher)

Calls TypeHash::type_hash on a value.
Source§

impl<L: Eq + Clone + 'static> Eq for LabeledVecGraph<L>

Source§

impl<L: Clone + 'static> LabeledSequentialGraph<L> for LabeledVecGraph<L>

Source§

impl<L: Clone + 'static> StructuralPartialEq for LabeledVecGraph<L>

Auto Trait Implementations§

§

impl<L> Freeze for LabeledVecGraph<L>

§

impl<L> RefUnwindSafe for LabeledVecGraph<L>
where L: RefUnwindSafe,

§

impl<L> Send for LabeledVecGraph<L>
where L: Send,

§

impl<L> Sync for LabeledVecGraph<L>
where L: Sync,

§

impl<L> Unpin for LabeledVecGraph<L>
where L: Unpin,

§

impl<L> UnsafeUnpin for LabeledVecGraph<L>

§

impl<L> UnwindSafe for LabeledVecGraph<L>
where L: UnwindSafe,

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> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V