Struct Partition

Source
pub struct Partition<G: Graph + ?Sized> { /* private fields */ }
Expand description

A partition of a the nodes of a graph.

Tarjan’s algorithm decomposes a directed graph into strongly connected components. Moreover, those components are ordered topologically.

Implementations§

Source§

impl<G: Graph + ?Sized> Partition<G>

Source

pub fn num_components(&self) -> usize

Source

pub fn parts<'b>(&'b self) -> impl Iterator<Item = &'b HashSet<G::Node>>

Source

pub fn part(&self, i: usize) -> &HashSet<G::Node>

Source

pub fn index_of(&self, u: &G::Node) -> usize

Source

pub fn into_parts(self) -> Vec<HashSet<G::Node>>

Trait Implementations§

Source§

impl<G: Graph + ?Sized> Graph for Partition<G>

Source§

type Node = usize

Source§

type Edge = usize

Source§

fn nodes<'a>(&'a self) -> Box<dyn Iterator<Item = usize>>

Source§

fn out_edges<'a>(&'a self, u: &usize) -> Box<dyn Iterator<Item = usize> + 'a>

Source§

fn in_edges<'a>(&'a self, u: &usize) -> Box<dyn Iterator<Item = usize> + 'a>

Source§

fn out_neighbors<'a>( &'a self, u: &Self::Node, ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(Self::Edge) -> Self::Node>

Source§

fn in_neighbors<'a>( &'a self, u: &Self::Node, ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(Self::Edge) -> Self::Node>

Source§

fn dfs<'a>(&'a self) -> Dfs<'a, Self>

Source§

fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>

Source§

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool

Source§

fn tarjan(&self) -> Partition<Self>

Source§

fn weak_components(&self) -> Partition<Self>

Source§

fn doubled<'a>(&'a self) -> Doubled<'a, Self>

Returns the graph that has edges in both directions for every edge that this graph has in one direction.
Source§

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F>
where F: Fn(&Self::Node) -> bool,

Returns the subgraph of this graph that is induced by the set of nodes for which predicate returns true.
Source§

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F>
where F: Fn(&Self::Node, &Self::Edge) -> bool,

Returns the subgraph of this graph containing all the edges for which the predicate returns true.
Source§

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>

If this graph is acyclic, returns a topological sort of the vertices. Otherwise, returns None.
Source§

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>

Source§

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>( &self, set: I, ) -> HashSet<Self::Node>
where Self::Node: 'a,

Returns the set of all nodes that are adjacent (either an in-neighbor or an out-neighbor) to something in set.

Auto Trait Implementations§

§

impl<G> Freeze for Partition<G>
where G: ?Sized,

§

impl<G> RefUnwindSafe for Partition<G>
where <G as Graph>::Node: RefUnwindSafe, G: ?Sized,

§

impl<G> Send for Partition<G>
where <G as Graph>::Node: Send, G: ?Sized,

§

impl<G> Sync for Partition<G>
where <G as Graph>::Node: Sync, G: ?Sized,

§

impl<G> Unpin for Partition<G>
where <G as Graph>::Node: Unpin, G: ?Sized,

§

impl<G> UnwindSafe for Partition<G>
where <G as Graph>::Node: UnwindSafe, G: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.