pub struct Graph<N: Clone, E: Clone> {
nodes: OrdMap<N, OrdMap<N, E>>,
}
Fields§
§nodes: OrdMap<N, OrdMap<N, E>>
Implementations§
Source§impl<N: Eq + Ord + Clone, E: Default + Clone> Graph<N, E>
impl<N: Eq + Ord + Clone, E: Default + Clone> Graph<N, E>
pub fn new() -> Graph<N, E>
pub fn add(&mut self, node: N)
pub fn link(&mut self, node: N, child: N) -> &mut E
pub fn contains<Q>(&self, k: &Q) -> bool
pub fn edge(&self, from: &N, to: &N) -> Option<&E>
pub fn edges(&self, from: &N) -> impl Iterator<Item = (&N, &E)>
fn sort_inner_visit(&self, node: &N, dst: &mut Vec<N>, marks: &mut BTreeSet<N>)
pub fn iter(&self) -> impl Iterator<Item = &N>
pub fn len(&self) -> usize
Sourcepub fn is_path_from_to<'a>(&'a self, from: &'a N, to: &'a N) -> bool
pub fn is_path_from_to<'a>(&'a self, from: &'a N, to: &'a N) -> bool
Checks if there is a path from from
to to
.
Sourcepub fn path_to_bottom<'a>(&'a self, pkg: &'a N) -> Vec<(&'a N, Option<&'a E>)>
pub fn path_to_bottom<'a>(&'a self, pkg: &'a N) -> Vec<(&'a N, Option<&'a E>)>
Resolves one of the paths from the given dependent package down to a leaf.
The path return will be the shortest path, or more accurately one of the paths with the shortest length.
Each element contains a node along with an edge except the first one. The representation would look like:
(Node0,) -> (Node1, Edge01) -> (Node2, Edge12)…
Sourcepub fn path_to_top<'a>(&'a self, pkg: &'a N) -> Vec<(&'a N, Option<&'a E>)>
pub fn path_to_top<'a>(&'a self, pkg: &'a N) -> Vec<(&'a N, Option<&'a E>)>
Resolves one of the paths from the given dependent package up to the root.
The path return will be the shortest path, or more accurately one of the paths with the shortest length.
Each element contains a node along with an edge except the first one. The representation would look like:
(Node0,) -> (Node1, Edge01) -> (Node2, Edge12)…
Source§impl<N: Eq + Ord + Clone, E: Clone> Graph<N, E>
impl<N: Eq + Ord + Clone, E: Clone> Graph<N, E>
Sourcefn print_for_test(&self)
fn print_for_test(&self)
Prints the graph for constructing unit tests.
For purposes of graph traversal algorithms the edge values do not matter, and the only value of the node we care about is the order it gets compared in. This constructs a graph with the same topology but with integer keys and unit edges.
Trait Implementations§
impl<N: Eq + Ord + Clone, E: Eq + Clone> Eq for Graph<N, E>
Auto Trait Implementations§
impl<N, E> Freeze for Graph<N, E>
impl<N, E> RefUnwindSafe for Graph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> !Send for Graph<N, E>
impl<N, E> !Sync for Graph<N, E>
impl<N, E> Unpin for Graph<N, E>
impl<N, E> UnwindSafe for Graph<N, E>
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> 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
§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
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes