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
impl GraphAnalysis
Sourcepub fn reads_from(&self, port: &Port) -> PortIterator<'_>
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.
Sourcepub fn writes_to(&self, port: &Port) -> PortIterator<'_>
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.
Sourcepub fn add_edges(self, edges: &[(RRC<Port>, RRC<Port>)]) -> Self
pub fn add_edges(self, edges: &[(RRC<Port>, RRC<Port>)]) -> Self
Add each edge in edges
to the graph.
Sourcepub fn toposort(&self) -> PortIterator<'_>
pub fn toposort(&self) -> PortIterator<'_>
Return a topological sort of this graph.
Sourcepub fn paths(&self, start: &Port, finish: &Port) -> Vec<Vec<RRC<Port>>>
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.
Sourcepub fn edge_induced_subgraph<F>(self, filter: F) -> Self
pub fn edge_induced_subgraph<F>(self, filter: F) -> Self
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.
Sourcepub fn remove_isolated_vertices(self) -> Self
pub fn remove_isolated_vertices(self) -> Self
Remove all vertices that have no undirected neighbors from the analysis graph.
Sourcepub fn has_cycles(&self) -> bool
pub fn has_cycles(&self) -> bool
Checks if there are cycles in the analysis graph.
Trait Implementations§
Source§impl Clone for GraphAnalysis
impl Clone for GraphAnalysis
Source§fn clone(&self) -> GraphAnalysis
fn clone(&self) -> GraphAnalysis
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GraphAnalysis
impl Debug for GraphAnalysis
Source§impl Default for GraphAnalysis
impl Default for GraphAnalysis
Source§fn default() -> GraphAnalysis
fn default() -> GraphAnalysis
Source§impl Display for GraphAnalysis
impl Display for GraphAnalysis
Source§impl From<&Component> for GraphAnalysis
impl From<&Component> for GraphAnalysis
Auto Trait Implementations§
impl Freeze for GraphAnalysis
impl !RefUnwindSafe for GraphAnalysis
impl !Send for GraphAnalysis
impl !Sync for GraphAnalysis
impl Unpin for GraphAnalysis
impl !UnwindSafe for GraphAnalysis
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