pub struct VecGraph(/* private fields */);Expand description
A mutable RandomAccessGraph implementation based on a vector of
vectors.
This implementation is faster and uses less resources than a BTreeGraph,
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.
§Implementation Notes
This is just a newtype for a LabeledVecGraph with
() labels. All
mutation methods are delegated.
Implementations§
Source§impl VecGraph
impl VecGraph
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)
pub fn add_arc(&mut self, u: usize, v: usize)
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> + 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> + 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> + 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> + 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> + 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> + 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> + 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> + 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)>)
pub fn add_arcs(&mut self, arcs: impl IntoIterator<Item = (usize, usize)>)
Add arcs from an IntoIterator, adding new nodes as needed.
The items must be pairs of the form (usize, usize) specifying an arc.
Sourcepub fn from_arcs(arcs: impl IntoIterator<Item = (usize, usize)>) -> Self
pub fn from_arcs(arcs: impl IntoIterator<Item = (usize, usize)>) -> Self
Creates a new graph from an IntoIterator.
The items must be pairs of the form (usize, usize) specifying an arc.
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 AlignHash for VecGraph
impl AlignHash for VecGraph
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 DeserInner for VecGraph
impl DeserInner for VecGraph
Source§type DeserType<'__epserde_desertype> = VecGraph
type DeserType<'__epserde_desertype> = VecGraph
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> IntoLender for &'a VecGraph
Convenience implementation that makes it possible to iterate
over the graph using the for_ macro
(see the crate documentation).
impl<'a> IntoLender for &'a VecGraph
Convenience implementation that makes it possible to iterate
over the graph using the for_ macro
(see the crate documentation).
Source§impl RandomAccessGraph for VecGraph
impl RandomAccessGraph for VecGraph
Source§impl RandomAccessLabeling for VecGraph
impl RandomAccessLabeling for VecGraph
Source§impl SequentialLabeling for VecGraph
impl SequentialLabeling for VecGraph
type Label = usize
Source§type Lender<'a> = LenderImpl<'a, VecGraph>
where
Self: 'a
type Lender<'a> = LenderImpl<'a, VecGraph> 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 SerInner for VecGraph
impl SerInner for VecGraph
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 = VecGraph
type SerType = VecGraph
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 SplitLabeling for VecGraph
impl SplitLabeling for VecGraph
type SplitLender<'a> = Take<<VecGraph as SequentialLabeling>::Lender<'a>> where Self: 'a
type IntoIterator<'a> = Iter<'a, VecGraph> where Self: 'a
fn split_iter(&self, how_many: usize) -> Self::IntoIterator<'_>
Source§impl TypeHash for VecGraph
impl TypeHash for VecGraph
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 Eq for VecGraph
impl SequentialGraph for VecGraph
impl StructuralPartialEq for VecGraph
Auto Trait Implementations§
impl Freeze for VecGraph
impl RefUnwindSafe for VecGraph
impl Send for VecGraph
impl Sync for VecGraph
impl Unpin for VecGraph
impl UnsafeUnpin for VecGraph
impl UnwindSafe for VecGraph
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> Deserialize for T
impl<T> Deserialize for T
Source§unsafe fn deserialize_full(backend: &mut impl ReadNoStd) -> Result<T, Error>
unsafe fn deserialize_full(backend: &mut impl ReadNoStd) -> Result<T, Error>
§Safety
See the documentation of Deserialize.
Source§unsafe fn deserialize_eps(
backend: &[u8],
) -> Result<<T as DeserInner>::DeserType<'_>, Error>
unsafe fn deserialize_eps( backend: &[u8], ) -> Result<<T as DeserInner>::DeserType<'_>, Error>
§Safety
See the documentation of Deserialize.
Source§unsafe fn load_full(path: impl AsRef<Path>) -> Result<Self, Error>
unsafe fn load_full(path: impl AsRef<Path>) -> Result<Self, Error>
Source§unsafe fn read_mmap(
read: impl ReadNoStd,
size: usize,
flags: Flags,
) -> Result<MemCase<Self>, Error>
unsafe fn read_mmap( read: impl ReadNoStd, size: usize, flags: Flags, ) -> Result<MemCase<Self>, Error>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
Source§unsafe fn ser_on_field_write(
&self,
backend: &mut impl WriteWithNames,
) -> Result<(), Error>
unsafe fn ser_on_field_write( &self, backend: &mut impl WriteWithNames, ) -> Result<(), Error>
WriteWithNames. Read more