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>
impl<L: Clone + 'static> LabeledVecGraph<L>
Sourcepub fn add_node(&mut self, node: usize) -> bool
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.
Sourcepub fn add_arc(&mut self, u: usize, v: usize, l: L)
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.
Sourcepub fn add_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Self
pub fn add_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Self
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.
Sourcepub fn from_lender<I: IntoLender>(iter_nodes: I) -> Self
pub fn from_lender<I: IntoLender>(iter_nodes: I) -> Self
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.
Sourcepub fn add_sorted_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Selfwhere
I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender,
for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator,
pub fn add_sorted_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Selfwhere
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.
Sourcepub fn from_sorted_lender<I: IntoLender>(iter_nodes: I) -> Selfwhere
I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender,
for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator,
pub fn from_sorted_lender<I: IntoLender>(iter_nodes: I) -> Selfwhere
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.
Sourcepub fn add_exact_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Selfwhere
I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender,
for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator + ExactSizeIterator,
pub fn add_exact_lender<I: IntoLender>(&mut self, iter_nodes: I) -> &mut Selfwhere
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.
Sourcepub fn from_exact_lender<I: IntoLender>(iter_nodes: I) -> Selfwhere
I::Lender: for<'next> NodeLabelsLender<'next, Label = (usize, L)> + SortedLender,
for<'succ> LenderIntoIter<'succ, I::Lender>: SortedIterator + ExactSizeIterator,
pub fn from_exact_lender<I: IntoLender>(iter_nodes: I) -> Selfwhere
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.
Sourcepub fn add_arcs(&mut self, arcs: impl IntoIterator<Item = ((usize, usize), L)>)
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.
Sourcepub fn from_arcs(arcs: impl IntoIterator<Item = ((usize, usize), L)>) -> Self
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.
Sourcepub fn shrink_to_fit(&mut self)
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>
impl<L: Clone + 'static> AlignHash for LabeledVecGraph<L>
Source§fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
hasher assuming to be positioned
at offset_of.Source§fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
AlignHash::align_hash on a value.Source§impl<L: Clone + Clone + 'static> Clone for LabeledVecGraph<L>
impl<L: Clone + Clone + 'static> Clone for LabeledVecGraph<L>
Source§fn clone(&self) -> LabeledVecGraph<L>
fn clone(&self) -> LabeledVecGraph<L>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<L: Clone + 'static> Default for LabeledVecGraph<L>
impl<L: Clone + 'static> Default for LabeledVecGraph<L>
Source§impl<L: Clone + 'static> DeserInner for LabeledVecGraph<L>
impl<L: Clone + 'static> DeserInner for LabeledVecGraph<L>
Source§type DeserType<'__epserde_desertype> = LabeledVecGraph<L>
type DeserType<'__epserde_desertype> = LabeledVecGraph<L>
DeserType.Source§fn __check_covariance<'__long: '__short, '__short>(
proof: CovariantProof<Self::DeserType<'__long>>,
) -> CovariantProof<Self::DeserType<'__short>>
fn __check_covariance<'__long: '__short, '__short>( proof: CovariantProof<Self::DeserType<'__long>>, ) -> CovariantProof<Self::DeserType<'__short>>
Source§unsafe fn _deser_full_inner(
backend: &mut impl ReadWithPos,
) -> Result<Self, Error>
unsafe fn _deser_full_inner( backend: &mut impl ReadWithPos, ) -> Result<Self, Error>
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>
unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>( backend: &mut SliceWithPos<'deser_eps_inner_lifetime>, ) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>
Source§impl From<LabeledVecGraph<()>> for VecGraph
impl From<LabeledVecGraph<()>> for VecGraph
Source§fn from(g: LabeledVecGraph<()>) -> Self
fn from(g: LabeledVecGraph<()>) -> Self
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).
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>
type Lender = <LabeledVecGraph<L> as SequentialLabeling>::Lender<'a>
Source§fn into_lender(self) -> Self::Lender
fn into_lender(self) -> Self::Lender
Lender.Source§impl<L: Clone + 'static> LabeledRandomAccessGraph<L> for LabeledVecGraph<L>
impl<L: Clone + 'static> LabeledRandomAccessGraph<L> for LabeledVecGraph<L>
Source§impl<L: Clone + 'static> RandomAccessLabeling for LabeledVecGraph<L>
impl<L: Clone + 'static> RandomAccessLabeling for LabeledVecGraph<L>
Source§impl<L: Clone + 'static> SequentialLabeling for LabeledVecGraph<L>
impl<L: Clone + 'static> SequentialLabeling for LabeledVecGraph<L>
type Label = (usize, L)
Source§type Lender<'a> = LenderImpl<'a, LabeledVecGraph<L>>
where
Self: 'a
type Lender<'a> = LenderImpl<'a, LabeledVecGraph<L>> where Self: 'a
Source§fn num_arcs_hint(&self) -> Option<u64>
fn num_arcs_hint(&self) -> Option<u64>
Source§fn iter_from(&self, from: usize) -> Self::Lender<'_>
fn iter_from(&self, from: usize) -> Self::Lender<'_>
from (included). Read moreSource§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
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
func to each chunk of nodes of size node_granularity in
parallel, and folds the results using fold. Read moreSource§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
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
func to each chunk of nodes containing approximately
arc_granularity arcs in parallel and folds the results using fold. Read moreSource§impl<L: Clone + 'static> SerInner for LabeledVecGraph<L>
impl<L: Clone + 'static> SerInner for LabeledVecGraph<L>
Source§const IS_ZERO_COPY: bool
const IS_ZERO_COPY: bool
ZeroCopy type has this constant set to false
serialization will panic.Source§type SerType = LabeledVecGraph<L>
type SerType = LabeledVecGraph<L>
Self, but
in some cases, as for references to slices,
it is customized.Source§unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
Source§impl<L: Clone + Sync> SplitLabeling for LabeledVecGraph<L>
impl<L: Clone + Sync> SplitLabeling for LabeledVecGraph<L>
type SplitLender<'a> = Take<<LabeledVecGraph<L> as SequentialLabeling>::Lender<'a>> where Self: 'a
type IntoIterator<'a> = Iter<'a, LabeledVecGraph<L>> where Self: 'a
fn split_iter(&self, how_many: usize) -> Self::IntoIterator<'_>
Source§impl<L: Clone + 'static> TypeHash for LabeledVecGraph<L>
impl<L: Clone + 'static> TypeHash for LabeledVecGraph<L>
Source§fn type_hash_val(&self, hasher: &mut impl Hasher)
fn type_hash_val(&self, hasher: &mut impl Hasher)
TypeHash::type_hash on a value.impl<L: Eq + Clone + 'static> Eq for LabeledVecGraph<L>
impl<L: Clone + 'static> LabeledSequentialGraph<L> for LabeledVecGraph<L>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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