pub struct ChainGraggle { /* private fields */ }
Expand description
A version of a Graggle
that has been decomposed into “chains” (for example, for
prettier rendering).
Most graggles that you’ll see in practice don’t look like general directed graphs. Rather, they contain lots of long “chains,” i.e., sequences of nodes, each of which has exactly one in-neighbor (the previous in the sequence) and one out-neighbor (the next). For example, a totally ordered graggle (a.k.a. a file) just consists of one long chain.
This struct represents the same graph as a graggle, except that every chain has been “collapsed”
into a single node. That is, you can think of a ChainGraggle
as a graph in which every node
represents a chain (possibly of length 1) in the original graph.
Implementations§
Source§impl ChainGraggle
impl ChainGraggle
Sourcepub fn num_chains(&self) -> usize
pub fn num_chains(&self) -> usize
How many chains are there?
Sourcepub fn chain(&self, i: usize) -> &[NodeId]
pub fn chain(&self, i: usize) -> &[NodeId]
Returns the sequence of NodeId
s making up the chain at index i
.
Sourcepub fn clusters(&self) -> impl Iterator<Item = &HashSet<usize>>
pub fn clusters(&self) -> impl Iterator<Item = &HashSet<usize>>
Returns an iterator over strongly connected components of the original graph.
Sourcepub fn from_graph<G: Graph<Node = NodeId>>(g: G) -> ChainGraggle
pub fn from_graph<G: Graph<Node = NodeId>>(g: G) -> ChainGraggle
Given a graph, decompose it into a ChainGraggle
.
Trait Implementations§
Source§impl Clone for ChainGraggle
impl Clone for ChainGraggle
Source§fn clone(&self) -> ChainGraggle
fn clone(&self) -> ChainGraggle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ChainGraggle
impl Debug for ChainGraggle
Source§impl<'de> Deserialize<'de> for ChainGraggle
impl<'de> Deserialize<'de> for ChainGraggle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Graph for ChainGraggle
In this implementation of graph::Graph
, the nodes are (semantically) chains in the original
graggle. More precisely, they are usize
s that you can use to get the chain with
ChainGraggle::chain
.
impl Graph for ChainGraggle
In this implementation of graph::Graph
, the nodes are (semantically) chains in the original
graggle. More precisely, they are usize
s that you can use to get the chain with
ChainGraggle::chain
.
type Node = usize
type Edge = usize
fn nodes(&self) -> Box<dyn Iterator<Item = usize> + '_>
fn out_edges(&self, u: &usize) -> Box<dyn Iterator<Item = usize> + '_>
fn in_edges(&self, _u: &usize) -> Box<dyn Iterator<Item = usize> + '_>
fn out_neighbors<'a>( &'a self, u: &Self::Node, ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(Self::Edge) -> Self::Node>
fn in_neighbors<'a>( &'a self, u: &Self::Node, ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(Self::Edge) -> Self::Node>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>
fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool
fn tarjan(&self) -> Partition<Self>
fn weak_components(&self) -> Partition<Self>
Source§fn doubled<'a>(&'a self) -> Doubled<'a, Self>
fn doubled<'a>(&'a self) -> Doubled<'a, Self>
Source§fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F>
fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F>
predicate
returns true
.Source§fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F>
fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F>
Source§fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>
fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>
None
.fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>
Auto Trait Implementations§
impl Freeze for ChainGraggle
impl RefUnwindSafe for ChainGraggle
impl Send for ChainGraggle
impl Sync for ChainGraggle
impl Unpin for ChainGraggle
impl UnwindSafe for ChainGraggle
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,
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>
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>
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