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
impl Graph
Sourcepub fn node(&mut self, id: impl Into<String>)
pub fn node(&mut self, id: impl Into<String>)
Add a node with the given id. The node’s label equals its id.
Sourcepub fn node_labeled(&mut self, id: impl Into<String>, label: impl Into<String>)
pub fn node_labeled(&mut self, id: impl Into<String>, label: impl Into<String>)
Add a node with the given id and label.
Sourcepub fn edge(&mut self, from_id: impl Into<String>, to_id: impl Into<String>)
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.
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more