pub enum ShortPath<V, E> {
Zero(V),
One(E),
}Expand description
A path of length at most one.
We call a path of length at most one, i.e., a path of lenth zero or one, a short path**. This is not standard terminology, though it is inspired by “short maps” between metric spaces, which are Lipschitz maps with Lipschitz constant at most 1.
Short paths are convertible into, and fallibly from, paths. Short paths might seem like an odd data structure, but are occasionally useful, such as in:
- finite categories defined by an explicit multiplication table, where every morphism is either a generator (path of length one) or an identity (path of length zero)
- augmented virtual double categories (Koudenburg 2020), where the codomain of a cell is by definition a short path, and relatedly unital virtual double categories
Variants§
Implementations§
Source§impl<V, E> ShortPath<V, E>
impl<V, E> ShortPath<V, E>
Sourcepub fn contained_in(&self, graph: &impl Graph<V = V, E = E>) -> bool
pub fn contained_in(&self, graph: &impl Graph<V = V, E = E>) -> bool
Is the path contained in the given graph?
Sourcepub fn src(&self, graph: &impl Graph<V = V, E = E>) -> Vwhere
V: Clone,
pub fn src(&self, graph: &impl Graph<V = V, E = E>) -> Vwhere
V: Clone,
Source of the path in the given graph.
Sourcepub fn tgt(&self, graph: &impl Graph<V = V, E = E>) -> Vwhere
V: Clone,
pub fn tgt(&self, graph: &impl Graph<V = V, E = E>) -> Vwhere
V: Clone,
Target of the path in the given graph.
Sourcepub fn as_edge(self, graph: &impl ReflexiveGraph<V = V, E = E>) -> E
pub fn as_edge(self, graph: &impl ReflexiveGraph<V = V, E = E>) -> E
Converts the short path into an edge in the given reflexive graph.
Trait Implementations§
impl<V: Eq, E: Eq> Eq for ShortPath<V, E>
impl<V, E> StructuralPartialEq for ShortPath<V, E>
Auto Trait Implementations§
impl<V, E> Freeze for ShortPath<V, E>
impl<V, E> RefUnwindSafe for ShortPath<V, E>where
V: RefUnwindSafe,
E: RefUnwindSafe,
impl<V, E> Send for ShortPath<V, E>
impl<V, E> Sync for ShortPath<V, E>
impl<V, E> Unpin for ShortPath<V, E>
impl<V, E> UnwindSafe for ShortPath<V, E>where
V: UnwindSafe,
E: 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
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>
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 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>
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§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.