Citizendia
Your Ad Here

DOT is a plain text graph description language. In Mathematics and Computer science, a graph is the basic object of study in Graph theory. A language is a dynamic set of visual auditory or tactile Symbols of Communication and the elements used to manipulate them It is a simple way of describing graphs that both humans and computer programs can use. DOT graphs are typically files that end with the . dot extension.

Various programs exist to process DOT files. These programs can read DOT files and render them, or provide an interface to manipulate the graphs. One such program, dot, is used by the source code documentation generator doxygen. Doxygen is a Documentation generator for C++, C, Java, Objective-C, Python, IDL ( Corba and Microsoft dot is part of the Graphviz package. Graphviz (short for Graph Visualization Software) is a package of open source tools initiated by AT&T Research Labs for drawing graphs specified

Contents

Syntax

Undirected Graphs

An undirected graph
An undirected graph

At its simplest, DOT can be used to describe an undirected graph. An undirected graph shows simple relations between objects, such as friendship between people. The graph keyword is used to begin a new graph, and nodes are described within curly braces. A double-hyphen (--) is used to show relations between the nodes.

graph graphname
{
    a -- b -- c;
    b -- d;
}

Directed Graphs

A directed graph
A directed graph

Similar to undirected graphs, DOT can describe directed graphs, such as flowcharts and dependency trees. The syntax is the same as for undirected graphs, except the digraph keyword is used to begin the graph, and an arrow (->) is used to show relationships between nodes.

digraph graphname
{
    a -> b -> c;
    b -> d;
}

Comments

DOT files are often generated by programs, but they can be hand edited as well. Dot supports C and C++ style comments. In addition, it ignores lines with a pound (#) symbol as their first character.

// This is a single line comment. 
/* This is a
   multi line
   comment.  */
# Lines like this are also ignored. 

Attributes

A graph with attributes
A graph with attributes

Various attributes can be applied to nodes and edges in DOT files. These attributes can control things such as color, shape, and line styles. Attributes are placed in square brackets ([]) after a statement and before the semicolon. Node attributes are placed after a statement containing only the name of the node, and no relations.

graph graphname
{
    // The label attribute can be used to change the label of a node
    a [label="Foo"];
    // Here, the node shape is changed. 
    b [shape=box];
    // These edges both have different line properties
    a -- b -- c [color=blue];
    b -- d [style=dotted];
}

A simple graph example

A visual rendering of the script by using the tool dotty
A visual rendering of the script by using the tool dotty

Following is an example script that describes the bonding structure of an ethane molecule. ETHANE is a mnemonic indicating a protocol used by Emergency services to report situations which they may be faced with especially as it relates to major incidents where This is an undirected graph and contains node attribues as explained above.

graph ethane {
    C_0 -- H_0 [type=s];
    C_0 -- H_1 [type=s];
    C_0 -- H_2 [type=s];
    C_0 -- C_1 [type=s];
    C_1 -- H_3 [type=s];
    C_1 -- H_4 [type=s];
    C_1 -- H_5 [type=s];
}

Layout Programs

The DOT language defines a graph, but does not provide facilities for rendering the graph. There are several programs that can be used to render, view, and manipulate graphs in the DOT language:

Limitations of DOT

Image that does not look right
Image that does not look right

DOT is not feasible when one wants perfect control over layout details; its feature is requiring one to only specify connectivity, and allowing sophisticated automated graph-drawing algorithms to render images. Thus its output can be unexpected.

For example:

digraph g {
        node [shape=plaintext]
        A1 -> B1
        A2 -> B2
        A3 -> B3
        
        A1 -> A2 [label=f]
        A2 -> A3 [label=g]
        B2 -> B3 [label="g'"]
        B1 -> B3 [label="(g o f)'" tailport=s headport=s]

        { rank=same; A1 A2 A3 }
        { rank=same; B1 B2 B3 } 
}

After moving labels and arrows a bit, and changing font size of subscripts, the image looks correct.
After moving labels and arrows a bit, and changing font size of subscripts, the image looks correct.

There are two problems in the image above. The square on the right is not a perfect square and the label "(g o f)" is in the wrong place. Classification A square (regular Quadrilateral) is a special case of a Rectangle as it has four right angles and equal parallel sides

This can be fixed with Inkscape or other SVG editors. Inkscape is a free and Open source Vector graphics editor application

See also

External links


© 2009 citizendia.org; parts available under the terms of GNU Free Documentation License, from http://en.wikipedia.org
Dapyx Software network: MP3 Explorer | Ebook Manager | Zenithic