pub struct DiGraph<N>where
N: GraphNode,{ /* private fields */ }Expand description
A directed graph using reference-counted nodes.
Implementations§
Source§impl<N> DiGraph<N>where
N: GraphNode,
impl<N> DiGraph<N>where
N: GraphNode,
Sourcepub fn new(nodes: IndexSet<N>) -> DiGraph<N>
pub fn new(nodes: IndexSet<N>) -> DiGraph<N>
Initializes a new DiGraph from a set of source nodes.
Sourcepub fn nodes(&self) -> impl Iterator<Item = &N>
pub fn nodes(&self) -> impl Iterator<Item = &N>
Returns an iterator over the nodes in the graph.
Sourcepub fn remove_node(&mut self, node: &N) -> bool
pub fn remove_node(&mut self, node: &N) -> bool
Removes a node and all associated edges from the graph.
Sourcepub fn neighbors(&self, node: &N) -> impl Iterator<Item = &N>
pub fn neighbors(&self, node: &N) -> impl Iterator<Item = &N>
Returns an iterator to the immediate neighbors of a given node.
Sourcepub fn transitive_closure(&self, node: &N) -> IndexSet<N>
pub fn transitive_closure(&self, node: &N) -> IndexSet<N>
Returns all the nodes that can be reached by a given node
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 post_order_with_filter<F>(
&self,
filter: F,
) -> Result<IndexSet<N>, DiGraphError<N>>
pub fn post_order_with_filter<F>( &self, filter: F, ) -> Result<IndexSet<N>, DiGraphError<N>>
Returns the post-order ordering of the graph but only considering a subset of the nodes that satisfy the given filter.
Detects if there is a cycle in the graph.
Sourcepub fn retain_nodes(&mut self, keep: &IndexSet<N>)
pub fn retain_nodes(&mut self, keep: &IndexSet<N>)
Retains a subset of the nodes, and removes all edges in which the source or destination is not in the subset.
Trait Implementations§
impl<N> Eq for DiGraph<N>
impl<N> StructuralPartialEq for DiGraph<N>where
N: GraphNode,
Auto Trait Implementations§
impl<N> Freeze for DiGraph<N>
impl<N> RefUnwindSafe for DiGraph<N>where
N: RefUnwindSafe,
impl<N> !Send for DiGraph<N>
impl<N> !Sync for DiGraph<N>
impl<N> Unpin for DiGraph<N>
impl<N> UnsafeUnpin for DiGraph<N>
impl<N> UnwindSafe for DiGraph<N>where
N: 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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