Skip to main content

EdgeTypes

Struct EdgeTypes 

Source
pub struct EdgeTypes { /* private fields */ }
Expand description

The type of every edge of a graph in a depth-first search: tree, back, forward or cross edge, as EdgeType defines them.

The types depend on the search. Uses a depth-first search, without recursion. The search starts at the nodes in ascending order and takes the out-nodes of each node in ascending order, as DfsTraverser::run does. type_of returns the type of one edge, and Edges::of collects the edges of one type. Here, cfg is the control flow of a method with a loop and a branch: the edge next -> header closes the loop, and body -> next skips then:

let types = EdgeTypes::of(&cfg);
let loop_edge = types.type_of(cfg.edge_index_of(next, header).unwrap());
let forward_edges = Edges::of(&types, EdgeType::Forward);
// loop_edge: Back
// forward_edges: body -> next

A graph is a DAG (directed acyclic graph) exactly if it has no back edge. For the back edges alone, back_edges::of saves the classification of the other edges.

Instances are immutable and safe to share between threads (Send and Sync).

Memory: 1 byte per edge; an instance also shares the arrays of its graph.

Implementations§

Source§

impl EdgeTypes

Source

pub fn of(graph: &Graph) -> EdgeTypes

Returns the type of every edge of graph, from one depth-first search.

Time: O(node_count + edge_count). Memory: edge_count bytes for the result; while it runs, 4 bytes and 2 bits per node, and up to 8 x node_count bytes for the stack, which grows with the deepest path.

§Panics

With an invalid argument message if a depth-first path is longer than 2^30 - 5 nodes.

Source

pub fn type_of(&self, edge_index: u32) -> EdgeType

Returns the type of edge edge_index.

Time: O(1).

§Panics

With an index out of bounds message if edge_index is not in 0..edge_count.

Trait Implementations§

Source§

impl Clone for EdgeTypes

Source§

fn clone(&self) -> EdgeTypes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EdgeTypes

Source§

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

Formats the value using the given formatter. 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> 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.