Module graphviz_rust::cmd

source ·
Expand description

Utilities for executing the dot command line executable.

Important: users should have the dot command line executable installed. A download can be found here: https://graphviz.org/download/.

Additional information on controlling the output can be found in the graphviz docs on layouts and output formats.

§Example:

use dot_structures::*;
use dot_generator::*;
use graphviz_rust::attributes::*;
use graphviz_rust::cmd::{CommandArg, Format};
use graphviz_rust::exec;
use graphviz_rust::printer::{PrinterContext,DotPrinter};

fn graph_to_output(){
    let mut g = graph!(id!("id");
            node!("nod"),
            subgraph!("sb";
               edge!(node_id!("a") => subgraph!(;
                  node!("n";
                  NodeAttributes::color(color_name::black), NodeAttributes::shape(shape::egg))
              ))
          ),
          edge!(node_id!("a1") => node_id!(esc "a2"))
    );
    let graph_svg = exec(g, &mut PrinterContext::default(), vec![
        CommandArg::Format(Format::Svg),
    ]).unwrap();
}

fn graph_to_file(){
       let mut g = graph!(id!("id"));
       let mut ctx = PrinterContext::default();
       ctx.always_inline();
       let empty = exec(g, &mut ctx, vec![
          CommandArg::Format(Format::Svg),
          CommandArg::Output("1.svg".to_string())
      ]);
}

Enums§

  • Commandline arguments that can be passed to executable.
  • Various graphic and data formats for end user, web, documents and other applications.
  • Various algorithms for projecting abstract graphs into a space for visualization