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 edge or line color

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 the style

Set type of arrow head for edge lines

Set type of arrow tail for edge lines

Set the relative rank

Set the pen width for drawing lines

Set the arrow size

Set the font size

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.