Struct TreeBackedGraph

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

A directed graph with balanced computational complexity.

Complexity
add_vertex$O(\log |V|)$
add_edge$O(\log |V| + \log |E|)$
remove_edge$O(\log |E|)$
remove_vertex$O(\log |V| + |E’|)$, where $E’$ is the set of edges connecting to the vertex to remove.
vertex_size$O(1)$
iter_verticesamortized $O(1)$ and $O(\log |V|)$ in the worst cases.
contains_vertex$O(\log |V|)$
edge_size$O(1)$
iter_edgesamortized $O(1)$ and $O(\log |E|)$ in the worst cases.
contains_edge$O(\log |E|)$
find_edge$O(\log |E|)$
edges_connectingreturns in $O(\log |E|)$. amortized $O(1)$ and $O(\log |E|)$ in the worst cases on each call to .next.
in_edgesreturns in $O(\log |E|)$. amortized $O(1)$ and $O(\log |E|)$ in the worst cases on each call to .next.
out_edgesreturns in $O(\log |E|)$. amortized $O(1)$ and $O(\log |E|)$ in the worst cases on each call to .next.

Trait Implementations§

Source§

impl Clone for TreeBackedGraph

Source§

fn clone(&self) -> TreeBackedGraph

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 TreeBackedGraph

Source§

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

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

impl DirectedOrNot for TreeBackedGraph

Source§

const DIRECTED_OR_NOT: bool = true

When the graph is directed, it is true; otherwise, it is false.
Source§

impl EdgeShrinkableGraph for TreeBackedGraph

Source§

fn remove_edge(&mut self, edge: &EdgeId) -> Option<Edge>

Remove an edge from the graph. Read more
Source§

impl GrowableGraph for TreeBackedGraph

Source§

fn new() -> Self

Generate a new and empty graph.
Source§

fn add_vertex(&mut self) -> VertexId

Add a new vertex into the graph.
Source§

fn add_edge(&mut self, source: VertexId, sink: VertexId) -> EdgeId

Add a new edge from source to sink for directed graphs or between them for undirected graphs.
Source§

impl QueryableGraph for TreeBackedGraph

Source§

fn vertex_size(&self) -> usize

Number of vertices in the graph.
Source§

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

Iteration over all vertices in the graph.
Source§

fn contains_vertex(&self, v: &VertexId) -> bool

Whether a vertex is in the graph or not.
Source§

fn edge_size(&self) -> usize

Number of edges in the graph.
Source§

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

Iteration over all edges in the graph.
Source§

fn contains_edge(&self, e: &EdgeId) -> bool

Whether an edge is in the graph or not.
Source§

fn find_edge(&self, e: &EdgeId) -> Option<Edge>

Returns information about a specified edge in the graph.
Source§

fn in_edges(&self, v: &VertexId) -> Box<dyn Iterator<Item = Edge> + '_>

Iteration over all edges going into the vertex v. Read more
Source§

fn out_edges(&self, v: &VertexId) -> Box<dyn Iterator<Item = Edge> + '_>

Iteration over all edges going out of v. Read more
Source§

fn edges_connecting<'a, 'b>( &'a self, source: &'b VertexId, sink: &'b VertexId, ) -> Box<dyn Iterator<Item = Edge> + 'a>

Iteration over all edges between two vertices in undirected graphs or those from source to sink in directed graphs.
Source§

fn debug(&self) -> Box<dyn Debug + '_>
where Self: Sized,

Returns something can inspect into the graph.
Source§

fn debug_with_indent( &self, init_indent: usize, indent_step: usize, ) -> Box<dyn Debug + '_>
where Self: Sized,

Returns something can inspect into the graph, with customzied indentation.
Source§

impl VertexShrinkableGraph for TreeBackedGraph

Source§

fn remove_vertex( &mut self, vertex: &VertexId, ) -> Box<dyn Iterator<Item = Edge> + 'static>

Removes a vertex from the graph and all edges connected to this vertex. 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<G> DumpInGraphviz for G

Source§

fn dump_in_graphviz<W>(&self, out: &mut W, graph_name: &str) -> Result<()>
where W: Write,

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<G> SimpleCycles for G
where G: QueryableGraph,

Source§

fn simple_cycles( &self, ) -> Box<dyn Iterator<Item = Box<dyn Iterator<Item = Edge> + '_>> + '_>

Iterates over all simple cycles of a graph.
Source§

fn simple_cycles_reachable_from( &self, vert: &VertexId, ) -> Box<dyn Iterator<Item = Box<dyn Iterator<Item = Edge> + '_>> + '_>

Iterates over simple cycles only reachable from vert.
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<G> TopologicalSort for G
where G: QueryableGraph,

Source§

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

Iterates over vertices in the topological order.
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.