pub struct GraphAnalysis { /* private fields */ }
Expand description

Constructs a graph based representation of a component. Each node represents a ir::Port and each directed edge (X -> Y) means that X’s value written to Y.

Example

c.in = G[done] & b.done ? add.out

creates the edges:

add.out -> c.in
G[done] -> c.in
b.done -> c.in

This representation is useful for asking graph based queries such as all the reads from a port or all the write to a port.

Implementations§

source§

impl GraphAnalysis

source

pub fn reads_from(&self, port: &Port) -> PortIterator<'_>

Returns an iterator over all the reads from a port. Returns an empty iterator if this is an Input port.

source

pub fn writes_to(&self, port: &Port) -> PortIterator<'_>

Returns an iterator over all the writes to this port. Returns an empty iterator if this is an Output port.

source

pub fn add_edges(self, edges: &[(RRC<Port>, RRC<Port>)]) -> Self

Add each edge in edges to the graph.

source

pub fn toposort(&self) -> PortIterator<'_>

Return a topological sort of this graph.

source

pub fn paths(&self, start: &Port, finish: &Port) -> Vec<Vec<RRC<Port>>>

Return a Vec of paths from start to finish, each path a Vec of ports.

source

pub fn edge_induced_subgraph<F>(self, filter: F) -> Selfwhere F: FnMut(&Port, &Port) -> bool,

Restricts the analysis graph to only include edges that are specified by the filter.

filter is passed references to the src and dst of each edge. When filter(src, dst) is true, then the edge between src and dst is kept. Otherwise, it is removed.

source

pub fn ports(&self) -> Vec<RRC<Port>>

Returns all the Port associated with this instance.

source

pub fn remove_isolated_vertices(self) -> Self

Remove all vertices that have no undirected neighbors from the analysis graph.

source

pub fn has_cycles(&self) -> bool

Checks if there are cycles in the analysis graph.

Trait Implementations§

source§

impl Clone for GraphAnalysis

source§

fn clone(&self) -> GraphAnalysis

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 GraphAnalysis

source§

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

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

impl Default for GraphAnalysis

source§

fn default() -> GraphAnalysis

Returns the “default value” for a type. Read more
source§

impl From<&Component> for GraphAnalysis

source§

fn from(component: &Component) -> Self

Converts to this type from the input type.
source§

impl From<&Group> for GraphAnalysis

source§

fn from(group: &Group) -> Self

Converts to this type from the input type.
source§

impl ToString for GraphAnalysis

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.