Struct ChainGraggle

Source
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

Source

pub fn num_chains(&self) -> usize

How many chains are there?

Source

pub fn chain(&self, i: usize) -> &[NodeId]

Returns the sequence of NodeIds making up the chain at index i.

Source

pub fn clusters(&self) -> impl Iterator<Item = &HashSet<usize>>

Returns an iterator over strongly connected components of the original graph.

Source

pub fn from_graph<G: Graph<Node = NodeId>>(g: G) -> ChainGraggle
where G::Edge: Edge<NodeId>,

Given a graph, decompose it into a ChainGraggle.

Trait Implementations§

Source§

impl Clone for ChainGraggle

Source§

fn clone(&self) -> ChainGraggle

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChainGraggle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ChainGraggle

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Graph for ChainGraggle

In this implementation of graph::Graph, the nodes are (semantically) chains in the original graggle. More precisely, they are usizes that you can use to get the chain with ChainGraggle::chain.

Source§

type Node = usize

Source§

type Edge = usize

Source§

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

Source§

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

Source§

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

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>(&self, set: I) -> HashSet<Self::Node>
where I: Iterator<Item = &'a Self::Node>, Self::Node: 'a,

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

impl Serialize for ChainGraggle

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,