DOT language

DOT language

DOT is a plain text graph description language. 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 .gv (or .dot) extension. The .gv extension is preferred, as .dot also is used by Microsoft Office 2003.[1]

Various programs can process DOT files. Some, like dot, neato, twopi, circo, fdp, and sfdp, will read a DOT file and render it in graphical form. Others, like gvpr, gc, accyclic, ccomps, sccmap, and tred, will read a DOT file and perform calculations on the represented graph. Finally, others, like GVedit, KGraphEditor, lefty, dotty, and grappa, provide an interactive interface. Most programs are part of the Graphviz package or using it internally.

Contents

Syntax

Graph types

Undirected graphs

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

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;
 }

Attributes

A graph with attributes

Various attributes can be applied to nodes and edges in DOT files. These attributes can control aspects such as color, shape, and line styles. One or more attribute-value pairs are placed in square brackets ([]) after a statement and before the semicolon. Multiple attributes are separated by a comma and a space. 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];
 }

Comments

Dot supports C and C++ style single line and multiple line comments. In addition, it ignores lines with a number sign symbol (#) as their first character.

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

A simple example

A rendering of the example script using the tool dotty

Following is an example script that describes the bonding structure of an ethane molecule. This is an undirected graph and contains node attributes 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

Binary tree generated in Graphviz from a DOT description by an online Huffman Tree generator

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:

  • Graphviz - A collection of libraries and utilities to manipulate and render graphs
  • Grappa - A Java based graph editor and viewer based on Graphviz
  • Beluging - A Python & Google Cloud based viewer of DOT and Beluga extensions. [1]
  • Tulip can import dot files for analysis
  • OmniGraffle can import a subset of DOT, producing an editable document. (The result cannot be exported back to DOT, however.)
  • ZGRViewer, a GraphViz/DOT Viewer link
  • VizierFX, A Flex graph rendering library link
  • Gephi - an interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs

Limitations

An image that seems improperly rendered

It is possible to specify layout details with DOT, although not all tools that implement the DOT language pay attention to the position attributes. Thus, depending on the tools used, users must rely on automated layout algorithms (potentially resulting in unexpected output) or tediously hand-position nodes.

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.

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.

This can be fixed with Inkscape or other SVG editors. In some cases, this can also be fixed by using the pos attribute to specify a position.

Other Graph File Formats

See also

Notes

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Dot notation — can refer to: Newton s notation for differentiation (see also Notation for differentiation). Lewis dot notation also known as Electron dot notation Dot decimal notation Kepatihan notation Dotted note Dot product DOT language Dot notation is also… …   Wikipedia

  • Dot and the Kangaroo —   …   Wikipedia

  • Dot (diacritic) — · Dot Diacritics accent acute( …   Wikipedia

  • Dot and the Whale — Directed by Yoram Gross Written by John Palmer (screenplay) Music by Bob Young Release date(s) …   Wikipedia

  • Dot Goes to Hollywood — Directed by Yoram Gross Written by John Palmer Starring Robyn Moore Keith Scott Music by Guy Gross …   Wikipedia

  • Dot Branning — EastEnders character Portrayed by June Brown Tallulah Pitt Brown (flashback) Created by Julia Smith and Tony Holland …   Wikipedia

  • dot the i — Directed by Matthew Parkhill Produced by George Duffield Meg Thomson …   Wikipedia

  • Dot.Kill — Directed by John Irvin Written by Rob Malkani Andrew Charas …   Wikipedia

  • Dot and Tot of Merryland —   …   Wikipedia

  • Dot Dot Dot (magazine) — For other uses, see Dot (disambiguation). Dot Dot Dot is a magazine of visual culture produced end edited by graphic designers Stuart Bailey and Peter Bilak. Since Dot Dot Dot 7, each issue of the magazine has been widely available as a paperback …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”