Struct Graph

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

A builder for directed graph output. Construct using deviz::graph.

§Examples

let mut graph = deviz::graph("g");
graph.node_labeled("root", "ROOT");
graph.node("A");
graph.node("B");
graph.edge("root", "A");
graph.edge_labeled("root", "B", "edge label");

Implementations§

Source§

impl Graph

Source

pub fn node(&mut self, id: impl Into<String>)

Add a node with the given id. The node’s label equals its id.

Source

pub fn node_labeled(&mut self, id: impl Into<String>, label: impl Into<String>)

Add a node with the given id and label.

Source

pub fn edge(&mut self, from_id: impl Into<String>, to_id: impl Into<String>)

Define an unlabeled edge from the node with id from_id to the node with id to_id.

If a node id is used in an edge but there is no corresponding call to node or node_labeled, then the node will be added automatically.

Warning: The order that edges are displayed in the graph is not guaranteed to correspond to the order that they were defined. This will hopefully change in the future, but for now you should label all edges if their order matters.

Source

pub fn edge_labeled( &mut self, from_id: impl Into<String>, to_id: impl Into<String>, label: impl Into<String>, )

Define an edge from the node with id from_id to the node with id to_id with the given label.

Trait Implementations§

Source§

impl Debug for Graph

Source§

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

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

impl Drop for Graph

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnwindSafe for Graph

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> 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, 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.