Struct DirectedGraph

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

A mutable, single-threaded directed graph.

Implementations§

Source§

impl DirectedGraph

Source

pub fn new(vertex_count: Vertex) -> Self

Constructs a new graph without any edges having at most vertex_count vertices.

Source

pub fn has_edges(&self) -> bool

Source

pub fn from_edges_iter<I>(vertex_count: Vertex, edges: I) -> Self
where I: Iterator<Item = (Vertex, Vertex)>,

Source

pub fn from_dag(dag: &DirectedAcyclicGraph) -> Self

Source

pub fn get_vertex_count(&self) -> Vertex

Source

pub fn iter_edges(&self) -> impl Iterator<Item = (Vertex, Vertex)> + '_

Source

pub fn get_edge(&self, parent: Vertex, child: Vertex) -> bool

Source

pub fn set_edge(&mut self, parent: Vertex, child: Vertex)

Source

pub fn clear_edge(&mut self, parent: Vertex, child: Vertex)

Source

pub fn find_tree_root(&self) -> Option<Vertex>

Returns None if the graph has more than connected component or there’s no root.

Source

pub fn extend_with_children(&self, u: Vertex, children: &mut Vec<Vertex>)

Pushes vertices v at the end of children such that there’s an edge (u, v) in the graph.

Source

pub fn extend_with_parents(&self, v: Vertex, parents: &mut Vec<Vertex>)

Pushes vertices u at the end of parents such that there’s an edge (u, v) in the graph.

Source

pub fn iter_descendants_dfs( &self, start_vertex: Vertex, ) -> Box<dyn Iterator<Item = Vertex> + '_>

Visit all vertices reachable from vertex in a depth-first-search (DFS) order.

Source

pub fn iter_ancestors_dfs( &self, start_vertex: Vertex, ) -> Box<dyn Iterator<Item = Vertex> + '_>

Source

pub fn iter_vertices_dfs_post_order( &self, start_vertices: &[Vertex], ) -> Box<dyn Iterator<Item = Vertex> + '_>

Visit all vertices of a DAG in a depth-first-search postorder, i.e. emitting vertices only after all their descendants have been emitted first.

Source

pub fn iter_edges_dfs_post_order( &self, start_vertices: &[Vertex], ) -> Box<dyn Iterator<Item = (Vertex, Vertex)> + '_>

Visit nodes in a depth-first-search (DFS) emitting edges in postorder, i.e. each node is emitted only after all its descendants have been emitted.

Source

pub fn get_vertices_without_incoming_edges(&self) -> Vec<Vertex>

Returns “seed” vertices of a DAG from which a traversal may start so that the process covers all vertices in the graph.

Source

pub fn get_topologically_ordered_vertices(&self) -> Option<Vec<Vertex>>

Return a sequence of topologically ordered vertices of a digraph, or None if the digraph has a cycle.

Source

pub fn transitive_reduction(&self) -> DirectedGraph

Returns a new DAG that is a transitive reduction of a DAG.

Source

pub fn to_dot<W: Write>(&self, output: &mut W) -> Result<(), Error>

Outputs the DAG in the Graphviz DOT format.

Source

pub fn to_dot_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Trait Implementations§

Source§

impl Clone for DirectedGraph

Source§

fn clone(&self) -> DirectedGraph

Returns a duplicate 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 DirectedGraph

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V