Struct dot_writer::Scope [−][src]
pub struct Scope<'d, 'w> { /* fields omitted */ }
Expand description
A Scope
struct represents either a graph, digraph, subgraph or cluster.
Its the workhorse of the DOT writing, and can be used to create new sub-scopes,
add nodes, add edges, or adjust default attributes for any of the above.
The only way to construct a top level graph or digraph scope is to call the
DotWriter::graph
or DotWriter::digraph
functions on a new DotWriter
.
Implementations
Starts a new nested subgraph, returning another Scope for writing to that subgraph.
Starts a new nested cluster subgraph, returning another Scope for writing to it. A cluster is a special case of a subgraph which groups its child nodes together. See the “Subgraphs and Clusters” section of the Graphviz documentation for more information.
Creates a new node, with an automatic default id of the format node_x
where x is an incerementing integer. You don’t have to declare nodes before
using them in a call to Scope::edge
, but you do have to declare them using this
function if you want to set specifc attributes for this node (font etc).
The returned value can be used to get the automatically generated id, and also to set the attributes.
Creates a new node, with the specified id. You don’t have to declare nodes before
using them in a call to Scope::edge
, but you do have to declare them using this
function if you want to set specific attributes for this node (font etc).
The returned value can be used to get the assigned name, and also to set the attributes.
Add a new edge joining start_node_id
and end_node_id
nodes.
Note that nodes do not need to be already defined by Scope::node_auto
or by Scope::node_named
(unless you want to set node-specific attributes).
Arguments can be just strings, or you can use the Node::id
of an already
defined node:
use dot_writer::DotWriter; let mut output_bytes = Vec::new(); { let mut writer = DotWriter::from(&mut output_bytes); writer.set_pretty_print(false); let mut digraph = writer.digraph(); let a = digraph.node_auto().id(); digraph.edge(a, "b"); } assert_eq!( std::str::from_utf8(&output_bytes).unwrap(), "digraph{node_0;node_0->b;}" );
Add N-1 edges joining all node ids or subgraphs in the iterator,
in the same manner as Scope::edge
.
The return value will be None if less than 2 items are passed in.
use dot_writer::DotWriter; let mut output_bytes = Vec::new(); { let mut writer = DotWriter::from(&mut output_bytes); writer.set_pretty_print(false); let mut digraph = writer.digraph(); digraph.edges(["a", "b", "c"]); } assert_eq!( std::str::from_utf8(&output_bytes).unwrap(), "digraph{a->b->c;}" );
Trait Implementations
Sets an attribute. See the Graphviz documentation
for a full list of available names and values.
Set the arguement quote
to true if the value
should be written in quotes "
, to escape
any special characters. Not that any quote in the string need to be escaped before calling. Read more
Set arbitary html, useful for constructing more complex nodes
Set the display label for a graph, node or edge
Set the label to appear at the head of an edge
Set the label to appear at the tail of an edge
Set the color to fill the are with
Set the color of the font
Set the background color
Set the shape of a graph, subgraph, cluster or node
Set type of arrow head for edge lines
Set type of arrow tail for edge lines
Set the pen width for drawing lines
Set the arrow size
Set the font size
Auto Trait Implementations
impl<'d, 'w> !RefUnwindSafe for Scope<'d, 'w>
impl<'d, 'w> !UnwindSafe for Scope<'d, 'w>