pub struct LabeledBTreeGraph<L: Clone + 'static = ()> { /* private fields */ }
Expand description
A mutable LabeledRandomAccessGraph
implementation based on a vector of
BTreeSet
.
This implementation is slower and uses more resources than a
LabeledVecGraph
,
but it is more flexible as arcs can be added in any order.
By setting the feature serde
, this struct can be serialized and
deserialized using serde.
Implementations§
Source§impl<L: Clone + 'static> LabeledBTreeGraph<L>
impl<L: Clone + 'static> LabeledBTreeGraph<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.
§Panics
This method will panic if one of the given nodes is greater or equal than the number of nodes in the graph.
Sourcepub fn add_arc(&mut self, u: usize, v: usize, l: L) -> bool
pub fn add_arc(&mut self, u: usize, v: usize, l: L) -> bool
Add a labeled arc to the graph and return whether it is a new one.
Sourcepub fn remove_arc(&mut self, u: usize, v: usize) -> bool
pub fn remove_arc(&mut self, u: usize, v: usize) -> bool
Remove an arc from the graph and return whether it was present or not.
Sourcepub fn add_lender<I: IntoLender>(&mut self, iter_nodes: I)
pub fn add_lender<I: IntoLender>(&mut self, iter_nodes: I)
Add nodes and labeled successors from an IntoLender
yielding a
NodeLabelsLender
.
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
.
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 triples 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 triples 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)
Trait Implementations§
Source§impl<L: Clone + Clone + 'static> Clone for LabeledBTreeGraph<L>
impl<L: Clone + Clone + 'static> Clone for LabeledBTreeGraph<L>
Source§fn clone(&self) -> LabeledBTreeGraph<L>
fn clone(&self) -> LabeledBTreeGraph<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 LabeledBTreeGraph<L>
impl<L: Clone + 'static> Default for LabeledBTreeGraph<L>
Source§impl From<LabeledBTreeGraph> for BTreeGraph
impl From<LabeledBTreeGraph> for BTreeGraph
Source§fn from(g: LabeledBTreeGraph<()>) -> Self
fn from(g: LabeledBTreeGraph<()>) -> Self
Source§impl<'a, L: Clone + 'static> IntoLender for &'a LabeledBTreeGraph<L>
impl<'a, L: Clone + 'static> IntoLender for &'a LabeledBTreeGraph<L>
type Lender = <LabeledBTreeGraph<L> as SequentialLabeling>::Lender<'a>
fn into_lender(self) -> Self::Lender
Source§impl<L: Clone + 'static> LabeledRandomAccessGraph<L> for LabeledBTreeGraph<L>
impl<L: Clone + 'static> LabeledRandomAccessGraph<L> for LabeledBTreeGraph<L>
Source§fn successors(
&self,
node_id: usize,
) -> <Self as RandomAccessLabeling>::Labels<'_>
fn successors( &self, node_id: usize, ) -> <Self as RandomAccessLabeling>::Labels<'_>
Source§impl<L: Clone + 'static + PartialEq> PartialEq for LabeledBTreeGraph<L>
Manual implementation of PartialEq
. This implementation is necessary
because the private struct [Successor
] that we use to store in a
BTreeSet
the tuple (usize, Label)
implements PartialEq
ignoring
the label so to enforce the absence of duplicate arcs. This implies that the
derived implementation of PartialEq
would not check labels, so the same
graph with different labels would be equal, and this is not the intended
semantics.
impl<L: Clone + 'static + PartialEq> PartialEq for LabeledBTreeGraph<L>
Manual implementation of PartialEq
. This implementation is necessary
because the private struct [Successor
] that we use to store in a
BTreeSet
the tuple (usize, Label)
implements PartialEq
ignoring
the label so to enforce the absence of duplicate arcs. This implies that the
derived implementation of PartialEq
would not check labels, so the same
graph with different labels would be equal, and this is not the intended
semantics.
Source§impl<L: Clone + 'static> RandomAccessLabeling for LabeledBTreeGraph<L>
impl<L: Clone + 'static> RandomAccessLabeling for LabeledBTreeGraph<L>
Source§impl<L: Clone + 'static> SequentialLabeling for LabeledBTreeGraph<L>
impl<L: Clone + 'static> SequentialLabeling for LabeledBTreeGraph<L>
type Label = (usize, L)
Source§type Lender<'a> = IteratorImpl<'a, LabeledBTreeGraph<L>>
where
Self: 'a
type Lender<'a> = IteratorImpl<'a, LabeledBTreeGraph<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,
thread_pool: &ThreadPool,
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, thread_pool: &ThreadPool, 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: Succ<Input = usize, Output = usize>>(
&self,
func: F,
fold: R,
granularity: Granularity,
deg_cumul: &D,
thread_pool: &ThreadPool,
pl: &mut impl ConcurrentProgressLog,
) -> A
fn par_apply<F: Fn(Range<usize>) -> A + Sync, A: Default + Send, R: Fn(A, A) -> A + Sync, D: Succ<Input = usize, Output = usize>>( &self, func: F, fold: R, granularity: Granularity, deg_cumul: &D, thread_pool: &ThreadPool, 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 moreimpl<L: Clone + 'static + Eq> Eq for LabeledBTreeGraph<L>
impl<L: Clone + 'static> LabeledSequentialGraph<L> for LabeledBTreeGraph<L>
Auto Trait Implementations§
impl<L> Freeze for LabeledBTreeGraph<L>
impl<L> RefUnwindSafe for LabeledBTreeGraph<L>where
L: RefUnwindSafe,
impl<L> Send for LabeledBTreeGraph<L>where
L: Send,
impl<L> Sync for LabeledBTreeGraph<L>where
L: Sync,
impl<L> Unpin for LabeledBTreeGraph<L>
impl<L> UnwindSafe for LabeledBTreeGraph<L>where
L: RefUnwindSafe,
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<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