Difference between revisions of "Basics of dot"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Dot|Dot</yambe:breadcrumb> =Basics of dot= ==Introduction== dot can be used to draw directed or undirected graphs, that is, dot can be used to draw gra...")
 
m
 
Line 1: Line 1:
<yambe:breadcrumb>Dot|Dot</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Image processing tools]] > [[Dot]] > [[Basics of dot]]
=Basics of dot=


==Introduction==
==Introduction==
Line 58: Line 57:




 
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Image processing tools]] > [[Dot]] > [[Basics of dot]]
 
<yambe:breadcrumb>Dot|Dot</yambe:breadcrumb>

Latest revision as of 15:16, 24 August 2022

Home > CentOS > CentOS 6.x > Image processing tools > Dot > Basics of dot

Introduction

dot can be used to draw directed or undirected graphs, that is, dot can be used to draw graphs with nodes and edges. Note that dot is not used for drawing charts (or graphs) such as pie, line, bar, etc. Other tools or utilities should be used for drawing charts.

To draw graphs using dot one can write specification of the graph in a text file, called dot file. 'dot' uses this text file as input and draws various types of graphs based on options specified in the dot file or on the command line.


Syntax of dot file

A dot file contains specification of a graph which has following syntax:

[strict] (graph|digraph) name { statement-list }

Here, 'strict' option indicates that two edges between same set of nodes is not allowed. 'graph' and 'digraph' indicate whether graph is undirected or directed, respectively. 'name' is the name with which graph can be identified later. Finally 'statement-list' is used to specify how to draw graph, including properties of various nodes, edges, placing of various nodes, etc.


Different types of statements

Statements in a statement list can be of following different types:

[name=value];
These type of statements can be used to set default attribute values for the graph. The graph attributes allow specifying parameters such as separation between nodes, page size under which the graph should be constructed, layout which will dictate how nodes should be placed with respect to each other (circular, straight line, tree, etc.)
node [name=value];
These type of statements can be used to set default node attributes. These attributes can be used to set size of node, its shape (square, rectangle, ellipse), node label, label font properties, color of node, etc.
edge [name=val];
These type of statements can be used to set default edge attributes. Edge attributes allow configuring length of edge, label for edge, font properties for edge label, edge color, edge style (solid, dashed, dotted, etc.), edge arrow direction, etc.


Edge statements
In directed graphs edges are specified using:
<node1-name> -> <node2-name>

Whereas in case of undirected graphs edges are specified using:

<node1-name> -- <node2-name>


Node statements
Although nodes referred in an edge get created automatically, if some specific node attributes are desired then a node statement can be specified to set specific attributes for a node.


Note that all the statements end with semi-colon (;) to indicate end of statement.


Input and output format

dot program expects name of dot files as command-line argument. Further expected output format can be specified using '-T' option. To see which output formats are supported for given dot installstion use:

dot -Txxx

Note that there is no output format named xxx. Hence the above command would generate error where the error message would include information about the supported formats. Popular formats which dot supported at the time of writing are fig (Xfig), svg, ps, png, gif and dia.

Name of output file can be specified with the help of '-o option'. If name of output file is not specified output is sent to standard output and can be redirected appropriately.


Home > CentOS > CentOS 6.x > Image processing tools > Dot > Basics of dot