Struct depends::graphviz::GraphvizVisitor
source · pub struct GraphvizVisitor { /* private fields */ }
Available on crate feature
graphviz
only.Expand description
A Visitor which builds a Graphviz
representation of a given graph.
use depends::graphviz::GraphvizVisitor;
// Compose a graph.
let left = NumberInput::default().into_leaf();
let right = NumberInput::default().into_leaf();
let sum = Sum::default().into_node(Components::new(Rc::clone(&left), Rc::clone(&right)));
let graph = MyGraph { left, right, sum };
let mut visitor = GraphvizVisitor::new();
// Resolve the graph with this visitor.
// Be sure NOT to use `resolve_root`, as this will clear the visitor's state.
graph.sum.resolve(&mut visitor);
// A Graphviz representation is now available on the visitor!
assert_eq!(visitor.render().unwrap(), r#"
digraph G {
0[label="NumberInput"];
1[label="NumberInput"];
2[label="Sum"];
0 -> 2;
1 -> 2;
}
"#.trim());
Implementations§
Trait Implementations§
source§impl Debug for GraphvizVisitor
impl Debug for GraphvizVisitor
source§impl Default for GraphvizVisitor
impl Default for GraphvizVisitor
source§fn default() -> GraphvizVisitor
fn default() -> GraphvizVisitor
Returns the “default value” for a type. Read more
source§impl Visitor for GraphvizVisitor
impl Visitor for GraphvizVisitor
type Hasher = DefaultHasher
source§fn visit<N>(&mut self, node: &N) -> boolwhere
N: Identifiable,
fn visit<N>(&mut self, node: &N) -> boolwhere N: Identifiable,
Return true iff this node hasn’t been visited yet.
source§fn clear(&mut self)
fn clear(&mut self)
Clear the internal collection, prompting this visitor to revisit all
nodes on the next traversal.
source§fn touch<N>(&mut self, node: &N)where
N: Identifiable,
fn touch<N>(&mut self, node: &N)where N: Identifiable,
Touch the node. Useful for building graph visualisations.
source§fn leave<N>(&mut self, node: &N)where
N: Identifiable,
fn leave<N>(&mut self, node: &N)where N: Identifiable,
Undo a touch. Useful for building graph visualisations.