Expand description

The library allows to interact with graphviz format.

Description:

Essentially, it starts from 3 base methods:

  • parse: a source of a dot file in the dot notation. The output format is a Graph.
  • print: Graph and DotPrinter provides an ability to transform a graph into string following the notation
  • exec: an ability to execute a cmd graphviz engine into different formats and etc.

Examples:

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

fn parse_test() {
       let g: Graph = parse(r#"
       strict digraph t {
           aa[color=green]
           subgraph v {
               aa[shape=square]
               subgraph vv{a2 -> b2}
               aaa[color=red]
               aaa -> bbb
           }
           aa -> be -> subgraph v { d -> aaa}
           aa -> aaa -> v
       }
       "#).unwrap();

       assert_eq!(
           g,
           graph!(strict di id!("t");
             node!("aa";attr!("color","green")),
             subgraph!("v";
               node!("aa"; attr!("shape","square")),
               subgraph!("vv"; edge!(node_id!("a2") => node_id!("b2"))),
               node!("aaa";attr!("color","red")),
               edge!(node_id!("aaa") => node_id!("bbb"))
               ),
             edge!(node_id!("aa") => node_id!("be") => subgraph!("v"; edge!(node_id!("d") => node_id!("aaa")))),
             edge!(node_id!("aa") => node_id!("aaa") => node_id!("v"))
           )
       )
   }

fn print_test() {
       let mut g = graph!(strict di id!("id"));
       assert_eq!("strict digraph id {}".to_string(), g.print(&mut PrinterContext::default()));
   }

 fn output_test(){
    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();

 }

Modules

It allows to execute cmd engine passing extra parameters

It allows to transform a graph into a string carrying dot info according to the notation.

Macros

Structs

the component represents a attribute in the language.

the component represents a edge in the language.

the component represents the vital component, namely node in the lang.

the component represents a node_id in the language. The component turns up in the edges predominantly or as an id for a node.

the component represents a port in the language. It contains from id and direction. All can be optional separately but not at the same time.

the component represents a subgraph in the lang.

Enums

the component depicts a type of the edge, namely it is a pair of chain. From the graph point of view, it impacts a compact display only.

the component represents a graph in the lang.

the component represents a set of attributes with prefix denoting a type in the language.

the component represents a id in the language. The Anonymous is a virtual component to keep the other components consistent in case when a node or subgraph is anonymous

the component represents a wrapper to keep sustainability in subgraph and graph bodies.

the component represents an edge component.

Functions