pub struct DiGraph<N: Node> {
nodes: IndexSet<N>,
edges: IndexMap<N, IndexSet<N>>,
}
Expand description
A directed graph.
Fields§
§nodes: IndexSet<N>
The set of nodes in the graph.
edges: IndexMap<N, IndexSet<N>>
The directed edges in the graph. Each entry in the map is a node in the graph, and the set of nodes that it points to.
Implementations§
Source§impl<N: Node> DiGraph<N>
impl<N: Node> DiGraph<N>
Sourcepub fn new(nodes: IndexSet<N>) -> Self
pub fn new(nodes: IndexSet<N>) -> Self
Initializes a new DiGraph
from a vector of source nodes.
Sourcepub fn contains_node(&self, node: N) -> bool
pub fn contains_node(&self, node: N) -> bool
Returns true
if the graph contains the given node.
Sourcepub fn post_order(&self) -> Result<IndexSet<N>, DiGraphError<N>>
pub fn post_order(&self) -> Result<IndexSet<N>, DiGraphError<N>>
Returns the post-order ordering of the graph. Detects if there is a cycle in the graph.
Sourcepub fn retain_nodes(&mut self, nodes: &IndexSet<N>)
pub fn retain_nodes(&mut self, nodes: &IndexSet<N>)
Retains a subset of the nodes, and removes all edges in which the source or destination is not in the subset.
fn contains_cycle_from( &self, node: N, discovered: &mut IndexSet<N>, finished: &mut IndexSet<N>, ) -> Option<N>
Trait Implementations§
impl<N: Eq + Node> Eq for DiGraph<N>
impl<N: Node> StructuralPartialEq for DiGraph<N>
Auto Trait Implementations§
impl<N> Freeze for DiGraph<N>
impl<N> RefUnwindSafe for DiGraph<N>where
N: RefUnwindSafe,
impl<N> Send for DiGraph<N>where
N: Send,
impl<N> Sync for DiGraph<N>where
N: Sync,
impl<N> Unpin for DiGraph<N>where
N: Unpin,
impl<N> UnwindSafe for DiGraph<N>where
N: 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
§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
Checks if this value is equivalent to the given key. Read more
§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.§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
Checks if this value is equivalent to the given key. Read more
§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>
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